简体   繁体   English

管理包:PyCharm vs conda vs pip

[英]Managing packages: PyCharm vs conda vs pip

I'm new to Python and recently installed PyCharm 2016.3 on Windows 10. I'm also using Anaconda 3.我是 Python 新手,最近在 Windows 10 上安装了 PyCharm 2016.3。我也在使用 Anaconda 3。

I don't know much about package management and would like to understand it better.我对包管理不太了解,想更好地理解它。 Normally I just use conda update --all but I noticed (by checking the package list of my local PyCharm Interpreter) that this doesn't upgrade all packages to the latest version.通常我只使用conda update --all但我注意到(通过检查本地 PyCharm 解释器的包列表)这不会将所有包升级到最新版本。

One such package is Pillow of which there's a version 4.0.0 but conda (4.3.11) won't update it past 3.4.2.一个这样的包是 Pillow,其中有一个版本 4.0.0 但 conda (4.3.11) 不会更新它超过 3.4.2。 I tried conda install pillow: 4.0.0 and got:我试过conda install pillow: 4.0.0并得到:

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

Later I found out that Pillow is also available on conda-forge so I tried conda install -c conda-forge pillow=4.0.0 and got:后来我发现枕头也可以在 conda-forge 上使用,所以我尝试了conda install -c conda-forge pillow=4.0.0 Pillow conda install -c conda-forge pillow=4.0.0并得到:

The following NEW packages will be INSTALLED:

    libiconv:  1.14-vc14_4   conda-forge [vc14]
    libxml2:   2.9.3-vc14_9  conda-forge [vc14]
    olefile:   0.44-py35_0   conda-forge
    vc:        14-0          conda-forge

The following packages will be UPDATED:

    freetype:  2.5.5-vc14_2              [vc14] --> 2.7-vc14_0    conda-forge [vc14]
    jpeg:      8d-vc14_2                 [vc14] --> 9b-vc14_0     conda-forge [vc14]
    libtiff:   4.0.6-vc14_2              [vc14] --> 4.0.6-vc14_7  conda-forge [vc14]
    pillow:    3.4.2-py35_0              --> 4.0.0-py35_2  conda-forge

The following packages will be SUPERCEDED by a higher-priority channel:

    conda:     4.3.11-py35_0             --> 4.2.13-py35_0 conda-forge
    conda-env: 2.6.0-0                   --> 2.6.0-0       conda-forge
    qt:        4.8.7-vc14_9              [vc14] --> 4.8.7-vc14_6  conda-forge [vc14]

I decided not to proceed and instead tried pip install pillow .我决定不继续,而是尝试pip install pillow Since this command doesn't ask for confirmation the package was simply installed.由于此命令不要求确认软件包已简单安装。 Now when I type conda list I get:现在,当我输入conda list我得到:

Pillow                    4.0.0                     <pip>
pillow                    3.4.2                    py35_0

The package list of the PyCharm Interpreter now shows Pillow as being version 4.0.0 but conda update pillow still returns: PyCharm 解释器的包列表现在显示 Pillow 为 4.0.0 版,但conda update pillow仍然返回:

# All requested packages already installed.
pillow                    3.4.2                    py35_0

My questions are:我的问题是:

1) What should I rely on to keep all my packages up to date, without compatibility issues? 1)我应该依靠什么来保持我所有的包都是最新的,没有兼容性问题?

2) Why did conda install pillow: 4.0.0 return an error but conda install -c conda-forge pillow=4.0.0 didn't? 2) 为什么conda install pillow: 4.0.0返回错误但conda install -c conda-forge pillow=4.0.0没有?

3) What do the * next to pillow 4.0.0 and python 3.5 in the list of dependencies mean? 3) 依赖项列表中枕头 4.0.0 和 python 3.5 旁边的 * 是什么意思?

4) Since now I have both Pillow 3.4.2 (in /anaconda3/pkgs ) and Pillow 4.0.0 (in /anaconda3/lib/site-packages ) which one would be used if I imported Pillow? 4) 现在我有 Pillow 3.4.2(在/anaconda3/pkgs )和 Pillow 4.0.0(在/anaconda3/lib/site-packages )如果我导入 Pillow 会使用哪一个?

5) Does the superseding conda: 4.3.11-py35_0 --> 4.2.13-py35_0 conda-forge mean conda is getting downgraded? 5) 取代conda: 4.3.11-py35_0 --> 4.2.13-py35_0 conda-forge是否意味着conda: 4.3.11-py35_0 --> 4.2.13-py35_0 conda-forge正在降级?

6) What is the difference between the tags pip, py35_0, py35_4, np111py35_2, etc? 6) pip、py35_0、py35_4、np111py35_2等标签有什么区别?

7) PyCharm tells me there's a version 2.9.5 of package Jinja2 but both normal conda and conda-forge only find 2.9.4. 7) PyCharm 告诉我有 Jinja2 包的 2.9.5 版本,但普通 conda 和 conda-forge 都只能找到 2.9.4。 From which channel is PyCharm getting this information? PyCharm 从哪个渠道获取这些信息?

Ok, I can't answer all of your questions but here goes:好吧,我不能回答你所有的问题,但这里有:

1) Conda defers to the "pain up front" approach for handling dependency/conflict resolution. 1) Conda 遵循“预先痛苦”的方法来处理依赖项/冲突解决方案。 You'll have to get all of your packages to play nicely together in the repo's/channels that you have available to even make a package or keep them in an environment together.你必须让你的所有包在你可以制作包或将它们放在一个环境中的存储库/频道中很好地一起播放。 You can try running it with --force or --no-deps to try getting it in but ..... that can cause issues for you in the future (I don't know if that would even work with the later versions of conda, it changes a lot).您可以尝试使用 --force 或 --no-deps 运行它以尝试获取它,但是..... 将来可能会给您带来问题(我不知道这是否适用于更高版本conda,它改变了很多)。 Simply keeping packages up to date, and up to latest, I would just use pip.简单地保持包是最新的,并且是最新的,我只会使用 pip。 Its come a long way in the last few years ( https://glyph.twistedmatrix.com/2016/08/python-packaging.html )它在过去几年取得了长足的进步( https://glyph.twistedmatrix.com/2016/08/python-packaging.html

2) I am not completely sure, I believe it would have something to do with providing an explicit non-url channel for conda to look at. 2)我不完全确定,我相信这与为 conda 提供显式非 url 通道有关。 Typically you pass it the URL to the conda-forge repo (I think, again we don't use conda-forge internally).通常,您将 URL 传递给 conda-forge 存储库(我认为,我们再次不在内部使用 conda-forge)。

3) The * means you are ignoring the patch/build 4.0.0 == Major.Minor.Build. 3) * 表示您忽略了补丁/构建 4.0.0 == Major.Minor.Build。 Likewise, 3.5* == any version of 3.5同样,3.5* == 3.5 的任何版本

4) I would import pillow in a terminal, and then print out the module to see where its getting pulled from, why guess? 4)我会在终端中导入枕头,然后打印出模块以查看它是从哪里拉出来的,为什么要猜测?

5) pass (although I think so) 5)通过(虽然我是这么认为的)

6) 6)

  • pip : means you installed that package via pip. pip :表示您通过 pip 安装了该软件包。 It will not be picked up if you do conda list --explicit如果您执行conda list --explicit ,它将不会被拾取
  • py35_0 : has a requirement / only available to envs / packages that use python 3.5 py35_0 :有一个要求/仅适用于使用 python 3.5 的环境/包
  • py35_4 : not sure (always forget that one) py35_4 :不确定(总是忘记那个)
  • np111py35_2 : requires python3.5 and also numpy 1.11 (I think *) np111py35_2 :需要 python3.5 和 numpy 1.11(我认为 *)

7) I tend to steer clear of pycharm, I believe that you can inspect the python interpreter that pycharm is pointing at to see what environment its in. Based on the root environment, you can do a conda info and get a list of all of the channels you are pointing to. 7)我倾向于避开pycharm,我相信你可以检查pycharm指向的python解释器,看看它在什么环境中。基于root环境,你可以做一个conda信息并获得所有您指向的频道。

Note: if you are going to use conda, you may just want to add conda-forge to your channels list instead of passing the -c (but seeing how the other channels are organized should help you see how you should pass the -c flag)注意:如果您打算使用 conda,您可能只想将 conda-forge 添加到您的频道列表中,而不是传递 -c(但查看其他频道的组织方式应该有助于您了解应该如何传递 -c 标志)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM