在问这个之前,我提到了这些问题:
https://stackoverflow.com/a/1383009/5157633
https://stackoverflow.com/a/4987569/5157633
目前,我已经创建了一个虚拟环境,如下所示:
export PYTHONPATH=
virtualenv --no-site-packages env4
source env4/bin/activate
,然后安装以下软件包:
(env4) shuba@shuba-XPS-13-9360: pip install numpy==1.13.1
(系统numpy的v为1.15)
Collecting numpy==1.13.1
Using cached https://files.pythonhosted.org/packages/5f/d2/9fa0201944933afd6d059f1e32aa6bdb203b23ab62fc823d3adf36295b9a/numpy-1.13.1-cp27-cp27mu-manylinux1_x86_64.whl
Installing collected packages: numpy
Successfully installed numpy-1.13.1
就像熊猫一样。 但是,当我尝试安装以下其他软件包时:
(env4) shuba@shuba-XPS-13-9360: pip install python-dateutil==2.6.1
Collecting python-dateutil==2.6.1
Downloading https://files.pythonhosted.org/packages/4b/0d/7ed381ab4fe80b8ebf34411d14f253e1cf3e56e2820ffa1d8844b23859a2/python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
100% |████████████████████████████████| 194kB 4.9MB/s
Requirement already satisfied: six>=1.5 in ./env4/lib/python2.7/site-packages (from python-dateutil==2.6.1) (1.11.0)
Installing collected packages: python-dateutil
Found existing installation: python-dateutil 2.7.3
Uninstalling python-dateutil-2.7.3:
Successfully uninstalled python-dateutil-2.7.3
Successfully installed python-dateutil-2.6.1
表示它已替换系统上的python-dateutil。我还通过从虚拟环境外部运行pip冻结进行了检查。
我发现令人困惑的是dateutil存在于python2.7的dist-packages文件夹中,但仍得到了更新,而其他答案提到,virtualenv pip包含了原始安装中的内容。
pytz也发生了同样的事情:
(env4) shuba@shuba-XPS-13-9360: pip install pytz==2017.2
Collecting pytz==2017.2
Downloading https://files.pythonhosted.org/packages/55/62/e7cd0e15b76062d298413f14bb4ec3cd8568a22d274427f9c3c7286969f4/pytz-2017.2-py2.py3-none-any.whl (484kB)
100% |████████████████████████████████| 491kB 4.7MB/s
Installing collected packages: pytz
Found existing installation: pytz 2018.5
Uninstalling pytz-2018.5:
Successfully uninstalled pytz-2018.5
Successfully installed pytz-2017.2
是否可以解决我遇到的上述问题?