我发现MarkupSafe在主机环境中安装得很好,但在virtualenv中,pip默默地失败。
[user@host ~]$ virtualenv testenv
New python executable in testenv/bin/python2.7
Also creating executable in testenv/bin/python
Installing setuptools, pip...done.
[user@host ~]$ \. testenv/bin/activate
(testenv)[user@host ~]$ pip install
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
You must give at least one requirement to install (see "pip help install")
(testenv)[user@host ~]$ pip install --upgrade pip
You are using pip version 6.0.8, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.2-py2.py3-none-any.whl#md5=5ff9fec0be479e4e36df467556deed4d
Using cached pip-7.1.2-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 6.0.8
Uninstalling pip-6.0.8:
Successfully uninstalled pip-6.0.8
Successfully installed pip-7.1.2
(testenv)[user@host ~]$ pip install pip
Requirement already satisfied (use --upgrade to upgrade): pip in ./testenv/lib/python2.7/dist-packages
(testenv)[user@host ~]$ pip install markupsafe
Collecting markupsafe
Using cached MarkupSafe-0.23.tar.gz
Installing collected packages: markupsafe
Running setup.py install for markupsafe
Successfully installed markupsafe
(testenv)[user@host ~]$ pip install markupsafe
Collecting markupsafe
Using cached MarkupSafe-0.23.tar.gz
Installing collected packages: markupsafe
Running setup.py install for markupsafe
Successfully installed markupsafe
(testenv)[user@host ~]$ which python
~/testenv/bin/python
(testenv)[user@host ~]$ python
Python 2.7.10 (default, Dec 8 2015, 18:25:23)
[GCC 4.8.3 20140911 (Red Hat 4.8.3-9)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import markupsafe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named markupsafe
>>>
(testenv)[user@host ~]$ pip freeze
(testenv)[user@host ~]$
不确定下一步是什么,或者可能是谁的错。 我的下一步行动是什么?
添加:还针对virtualenv记录了一个问题:https://github.com/pypa/virtualenv/issues/836
答案 0 :(得分:4)
我在amazon linux 2015.09上遇到了同样的问题,使用twisted,它安装但是无法导入zope.interface和twisted.internet模块。我通过升级系统范围的virtualenv修复了它,以root身份运行:
git rebase -i
并重新创建了我的virtualenv。