问题描述
我试着从this回答他们似乎给被不同的结果。我使用的virtualenv
,我想知道如果有事情做这一点。第一种方法,从蟒壳(在虚拟环境被激活):
I tried multiple solutions from this answer and they seemed to give be different results. I am using virtualenv
and I was wondering if it has something to do with that. The first method, from the python shell (while the virtual environment is active):
import pip
installed_packages = pip.get_installed_distributions()
installed_packages_list = sorted(["%s==%s" % (i.key, i.version)
for i in installed_packages])
print(installed_packages_list)
这使输出
['distribute==0.6.34', 'django==1.8.1', 'flup==1.0.3.dev-20110405', 'importlib==1.0.3']
第二个方法,从bash shell中,再在虚拟环境是积极的:
The second method, from the bash shell, again while the virtual environment is active:
pip freeze
这给出了以下列表:
Warning: cannot find svn location for flup==1.0.3.dev-20110405
Django==1.8.1
Ksplice-Uptrack==1.2.12
MySQL-python==1.2.2
PIL==1.1.7
South==0.7.6
distribute==0.6.34
django-photologue==2.4
dnspython==1.11.1
ethtool==0.6
## FIXME: could not find svn URL in dependency_links for this package:
flup==1.0.3.dev-20110405
importlib==1.0.3
iniparse==0.3.1
iotop==0.3.2
iwlib==1.0
mercurial==1.4
pycurl==7.19.0
pygpgme==0.1
pyzor==1.0.0
urlgrabber==3.9.1
virtualenv==1.9.1
yum-metadata-parser==1.1.2
有人能解释一下为什么会这样?基本上,我希望能够从第二个列表导入包,但我不能(特别是我的Django的服务器无法导入MySQLdb的,像<一个href=\"https://stackoverflow.com/questions/2952187/getting-error-loading-mysqldb-module-no-module-named-mysqldb-have-tried-$p$p\">this问题,甚至没有尝试他们的答案后)。
Could someone explain why this is happening? Basically, I would like to be able to import packages from the second list, but I can't (in particular, my Django server is not able to import MySQLdb, like this question, even after trying their answers).
推荐答案
实现了什么问题...
Realized what the problem was...
pip -V
给
pip 1.3.1 from /home/benjam15/.env/env/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg
(python 2.6)
而我使用Python 2.7。其次点子命令传送到Python 2.6,而我真的很想东西安装Python 2.7版。
while I was using python 2.7. Followed this post since the server's default "pip" command routed to python 2.6, while I really wanted stuff to install for python 2.7.
这篇关于&QUOT; PIP冻结&QUOT;给出了&QUOT不同模块;帮助(“模块”)QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!