未包含在"conda env导出"中的pip包 [英] pip packages not included in "conda env export"

查看:96
本文介绍了未包含在"conda env导出"中的pip包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的python项目在conda虚拟环境上运行.只要有可用该方式安装的软件包,我就使用conda install在环境中安装软件包,否则,请使用pip install进行安装.

My python project runs on a conda virtual environment. I install packages on the environment with conda install whenever that package is available for installing that way, otherwise, I install it with pip install.

为了使其他开发人员更容易安装项目,我将在conda环境中使用的软件包列表导出到文件:conda env export > conda_environment_export.yml.

To make the project installation easier for other developers, I export the list of packages that are used on the conda environment to a file: conda env export > conda_environment_export.yml.

但是,一段时间以来,软件包导出不再包含pip安装的软件包.

However, since a while, the package export does no longer contain the packages installed by pip.

如何使pip包再次出现在导出中?

What can I do to make pip packages appear again in the export?

几周前的我的conda导出文件:

My conda export file as it was some weeks ago:

name: sensor_gateway
channels:
  - defaults
dependencies:
  - aiohttp=2.3.9=py36_0
  - async-timeout=2.0.0=py36hc3e01a3_0
  - certifi=2018.1.18=py36_0
  - chardet=3.0.4=py36h420ce6e_1
  - jinja2=2.10=py36h292fed1_0
  - markupsafe=1.0=py36h0e26971_1
  - multidict=3.3.2=py36h72bac45_0
  - pip=9.0.1=py36h226ae91_4
  - pymysql=0.7.11=py36hf59f3ba_0
  - python=3.6.4=h6538335_1
  - pytz=2018.3=py36_0
  - setuptools=38.4.0=py36_0
  - sqlalchemy=1.2.1=py36hfa6e2cd_0
  - vc=14=h0510ff6_3
  - vs2015_runtime=14.0.25123=3
  - wheel=0.30.0=py36h6c3ec14_1
  - wincertstore=0.2=py36h7fe50ca_0
  - yarl=0.14.2=py36h27d1bf2_0
  - pip:
    - aiohttp-jinja2==0.16.0
    - aiomysql==0.0.12
    - attrs==17.4.0
    - idna==2.6
    - idna-ssl==1.0.0
    - python-mimeparse==1.6.0
prefix: C:\ProgramData\Anaconda3\envs\sensor_gateway

conda现在正在导出:

The conda export now:

name: sensor_gateway
channels:
  - defaults
dependencies:
  - aiohttp=2.3.9=py36_0
  - async-timeout=2.0.0=py36hc3e01a3_0
  - certifi=2018.4.16=py36_0
  - chardet=3.0.4=py36h420ce6e_1
  - icc_rt=2017.0.4=h97af966_0
  - intel-openmp=2018.0.0=8
  - jinja2=2.10=py36h292fed1_0
  - markupsafe=1.0=py36h0e26971_1
  - mkl=2018.0.2=1
  - mkl_fft=1.0.1=py36h452e1ab_0
  - mkl_random=1.0.1=py36h9258bd6_0
  - multidict=3.3.2=py36h72bac45_0
  - numpy=1.14.2=py36h5c71026_1
  - pip=9.0.1=py36h226ae91_4
  - pymysql=0.7.11=py36hf59f3ba_0
  - python=3.6.4=h6538335_1
  - pytz=2018.3=py36_0
  - setuptools=38.4.0=py36_0
  - simplejson=3.14.0=py36hfa6e2cd_0
  - sqlalchemy=1.2.1=py36hfa6e2cd_0
  - vc=14=h0510ff6_3
  - vs2015_runtime=14.0.25123=3
  - wheel=0.30.0=py36h6c3ec14_1
  - wincertstore=0.2=py36h7fe50ca_0
  - yarl=0.14.2=py36h27d1bf2_0
prefix: C:\ProgramData\Anaconda3\envs\sensor_gateway

我怀疑更新conda(4.4.10-py36_0-> 4.5.2-py36_0)的版本可能导致此项目出现此问题.在另一个项目上,我遇到了同样的问题,但是我更新了pip(9.0.1-py36h226ae91_4-> 10.0.1-py36_0).即使返回到9.0.1点,问题仍然存在.我的怀疑正确吗?我该怎么做才能再次解决此问题?

I suspect that updating the version of conda (4.4.10-py36_0 --> 4.5.2-py36_0) may have caused this problem on this project. On another project, I have the same issue, but there I updated pip (9.0.1-py36h226ae91_4 --> 10.0.1-py36_0). Even after going back to pip 9.0.1 there, the problem remains. Is my suspicion correct? And what can I do to fix this again?

更新:

目前唯一建议的答案链接到这个问题,似乎并不能解决我的问题:

The only proposed answer right now links to this question and it does not seem to solve my problem:

1.在Windows命令终端上,以管理员身份打开:

where pip输出(where作为与Windows等效的命令,在unix/linux上为which):

where pip output (where as windows-equivalent command to which on unix/linux):

C:\ProgramData\Anaconda3\Scripts\pip.exe
C:\Users\Sander\AppData\Local\Programs\Python\Python36\Scripts\pip.exe

pip freeze输出:

列出我曾经在正常" python上安装的所有软件包(=默认情况下安装的所有软件包,而不是在任何专用的虚拟环境中).软件包列表太长,无法包含在此处.

2.在Windows命令终端上,以管理员权限打开并执行activate sensor_gateway

2. On a Windows command terminal, opened with administrator privileges, and after executing activate sensor_gateway:

where pip输出:

C:\ProgramData\Anaconda3\envs\sensor_gateway\Scripts\pip.exe
C:\ProgramData\Anaconda3\Scripts\pip.exe
C:\Users\Sander\AppData\Local\Programs\Python\Python36\Scripts\pip.exe

pip freeze输出:

正确列出在环境上用pip安装的所有软件包.

lists all packages installed with pip on my environment correctly.

因此,似乎在激活我的虚拟环境时,在该环境中安装了一个pip,并且必须是那个 pip,它会在需要时返回已安装软件包的列表,而不是另一个pip安装,因为环境上的pip软件包列表正确.

So it seems that when my virtual environment is activated, there is a pip installed in that environment, and it must be that pip that returns the list of installed packages when asked for, not another pip install, since the pip package list on the environment is correct.

推荐答案

我能够通过在具有管理员权限的命令窗口中运行此命令来解决此问题:

I was able to solve this problem just by running this in a command window with admin privileges:

activate <env-name>
conda update pip

此后,在我的环境中,可用软件包的导出又包含了conda安装的软件包和pip安装的软件包.

After that, exports of the available packages on my environment contain again both the packages installed with conda and those with pip.

我怀疑可能是造成此软件包导出问题的原因,因为我在执行软件包安装时遵循了pip先前给出的说明:

I suspect I may have caused this package export problem because I had followed the instruction that pip gave earlier on, when I was executing a package install:

"您正在使用pip版本9.0.3,但是可以使用版本10.0.1. 您应该考虑通过"python -m pip install --upgrade pip">命令进行升级."

"You are using pip version 9.0.3, however version 10.0.1 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' > command."

因此,用python -m pip install --upgrade pip更新破坏了我的包裹出口,但conda update pip修复了它.

So updating with python -m pip install --upgrade pip broke my package exports, but conda update pip fixed it.

这篇关于未包含在"conda env导出"中的pip包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆