当有已安装的包与旧包链接时,安装更新的 Python

Install a newer Python when there are installed packages linked against the old one

(请耐心等待我的详细描述,这是一段相当长的故障排除之旅。)

我的最终目标 是让 python 包 graph_tool 在我的系统上工作,如果可能的话也在 ipynb 上工作。我已经brew install graph-toolas indicated here,但还是不够

所以我遵循 conda instructions here,并尝试满足所有要求,包括 cgalpython3.6。我最初有 python2.7 和 python3.5 的 anaconda,但由于 python3.6 是必需的,所以我下载了 python3.6 的 anaconda3。 (conda update python还是一直给我3.5)

我删除了 /Users/mymacbook/anaconda,这样 /Users/mymacbook/anaconda3 就会成为默认的搜索目录。我有一个小小的成功!

$ python3
Python 3.6.2 |Anaconda, Inc.| (default, Sep 21 2017, 18:29:43) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

不幸的是,当我继续 conda install 所需的其他软件包(boost、cgal 等)时,我的 python3 恢复为 3.5 :(

$ python3
Python 3.5.4 |Anaconda custom (x86_64)| (default, Oct  5 2017, 02:58:14)

$ conda install python=3.6
Fetching package metadata ...........
Solving package specifications: .

UnsatisfiableError: The following specifications were found to be in conflict:
  - cgal -> python 3.5*
  - python 3.6*
Use "conda info <package>" to see the dependencies for each package.

$ conda info cgal
Fetching package metadata ...........

ResolvePackageNotFound: 
  - cgal

相当困难,不是吗...由于 ResolvePackageNotFound,建议卸载 cgal,但就像我提到的,我需要 cgal 和 python3.6.

在此先感谢您的帮助! (请在您的建议中包含适用的命令行 - 我是初学者)

您安装的 cgal 副本是为 Python 3.5 编译的。如果您查看 https://anaconda.org/conda-forge/cgal/files ,每个 Python 次要版本都有一个单独的包。

Managing Python — Conda documentation 推荐

  • 如果您不想替换现有安装,则在新环境中安装新的 Python,或者
  • update如果你确实想替换当前的
  • 'ing它(如果需要,连同其他包)

当然,您也可以卸载所有特定于版本的包,安装新的 Python,然后重新安装这些包 - 但这样更麻烦。

Looking for Packages 当您执行 conda create ..conda install ... 甚至 conda search 时,它只会向您显示一致的结果使用您的 OS,在某些情况下,基本 python 版本。

真正可用的东西 你可以直接去Anaconda.org搜索你的包裹。这将在 "official" anaconda 分发包以外的渠道上构建。但是,在查看此处时,您必须手动查看可用的文件,因为有些文件可能不是为您的 os.

构建的

查看 conda info 的结果以查看您当前的频道。看来频道 "conda-forge" 可能有您想要的内容。

conda create -n tamtams_project ipython cgal --channel conda-forge

当我偏离默认渠道时,我更愿意知道包裹来自哪里。您始终可以通过使用以下命令添加到您的 .condarc 文件来查看该信息:

conda config --set show_channel_urls True

上面的创建将显示几乎所有的包都是 conda-forge 包,因为命令行通道成为首选通道。

所以,一个次要的偏好可能是使用:

conda create -n tamtams_project ipython cgal -c defaults -c conda-forge 

然后您会看到 most 个包是默认包,两个来自 conda-forge。