我正在使用以下 requirements.txt
文件在Ubuntu 12.04中安装多个Python包:
numpy>=1.8.2,<2.0.0
matplotlib>=1.3.1,<2.0.0
scipy>=0.14.0,<1.0.0
astroML>=0.2,<1.0
scikit-learn>=0.14.1,<1.0.0
rpy2>=2.4.3,<3.0.0
以及这两个命令:
$ pip install --download=/tmp -r requirements.txt
$ pip install --user --no-index --find-links=/tmp -r requirements.txt
第一个下载包,第二个安装它们。
该过程经常因错误而停止:
Could not find a version that satisfies the requirement <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2)) (from versions: )
No matching distribution found for <package> (from matplotlib<2.0.0,>=1.3.1->-r requirements.txt (line 2))
我手动修复它,使用以下方法:
pip install --user <package>
然后再次运行第二个pip install
命令即可。
但这仅适用于该特定软件包。当我再次运行第二个pip install
命令时,该过程现在会停止,并抱怨需要安装另一个必需软件包,我需要重复这个过程,即手动安装新的必需软件包(使用上面的命令),然后再次运行第二个pip install
命令。
到目前为止,我不得不手动安装了six
、pytz
、nose
,现在它又需要安装mock
了。
有没有一种方法可以告诉pip
自动安装所有需要的依赖项,以便我不必一个一个手动安装?
补充:顺便说一下,这只发生在Ubuntu 12.04中。在Ubuntu 14.04中,应用于requirements.txt
文件的pip install
命令可以正常工作。
conda create -n my_anatome_env python=3.9; conda activate my_anatome_env
解决了这个问题,然后再进行 pip 安装。 - Charlie Parker