python-3.x - Python pip 和 conda 包管理器

标签 python-3.x pip pycharm anaconda conda

是的,我在 python 世界中问同样的老问题。关于包管理器 pipconda

Pippython 包完美配合,但会卡在带有 c 扩展的 python 包(如 pandas、matplotlib 等)中。这就是 conda 的用武之地,以节省设置环境的时间。 然而,我偶然发现了一些环境,其中 conda channel 没有像 flask-sqlalchemy、flask-httpauth 等包。所以你必须为此使用 pip。使用两个不同的包管理器管理您的环境对我来说听起来很奇怪,可能是不可取的。

使用此类包管理器管理 python 依赖项的最佳实践是什么。需要高手指教,感觉中的差距。

任何想法/帮助将不胜感激。

我也用 Pycharm,它只能识别 conda 包,不能识别 pip 包。那是另一种痛苦。所以我不得不回到 vim(这很好 - 我喜欢它)但是调试很困难,或者不像 IDE 那样像 pycharm 那样容易。

附言我使用 Linux/Mac 进行开发。

最佳答案

这是一个不错的工作流程示例(来自 this blog ):

  1. Create a project folder in the ~/repos/ directory on my computer.
  2. Create an environment.yml file in the directory. Typically the environment name will be the same as the folder name. At minimum, it will specify the version of Python I want to use; it will often include anaconda as a dependency.
  3. Create the conda environment with $ conda env create.
  4. Activate the conda environment with $ source activate ENV_NAME.
  5. Create a .env file containing the line source activate ENV_NAME. Because I have autoenv installed, this file will be run every time I navigate to the project folder in the Terminal. Therefore, my conda environment will be activated as soon as I navigate to the folder.
  6. Run $ git init to make the folder a Git repository. I then run $ git add environment.yml && git commit -m 'initial commit' to add the YAML file to the repository.
  7. If I want to push the repository to Github, I use $ git create using Github's hub commands. I then push the master branch with $ git push -u origin master.

它还不错,但并不完美。一些缺 pip 是:

  1. 直接依赖与依赖的依赖一起列出。
  2. 正确删除包很复杂。
  3. 当有从其他来源安装的包时,它不起作用。

但是,这是一个好的开始,根据我的经验,大多数团队都不会费心去发明比这个更好的解决方案。

附注:去年,PyCharm 显着改进了对 conda 的支持,截至 2017 年 4 月,它可以正确识别 conda 和 pip 包。

关于python-3.x - Python pip 和 conda 包管理器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36180868/

相关文章:

python - PyCharm 未检测到 anaconda3 环境

python - Django 的两个字段之一不能为空

python - 一个简单的 Hello World setuptools 包并使用 pip 安装它

python - PyCharm 将多个 df 导出到单个 csv 文件

python - PyCharm 看不到项目中的文件

python - pip3 导入错误 : cannot import name 'IncompleteRead'

Python 在迭代文件行时无法更改变量的值

python - re.split后,如何把分隔符放回去?

linux - 防止 matplotlib 提高数字

python - 为 blender 安装 numpy