0

Python,Django 1.3.5
我正在使用 virtualenv,sudo pip install PyCrypto==2.6,它成功了。
但是Django的错误:

Traceback (most recent call last):
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/core/servers/basehttp.py", line 283, in run
self.result = application(self.environ, self.start_response)
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 272, in __call__
response = self.get_response(request)
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 169, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/core/handlers/base.py", line 214, in handle_uncaught_exception
if resolver.urlconf_module is None:
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/core/urlresolvers.py", line 274, in _get_urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Users/zhanglei/Develop/medweb-env/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/zhanglei/Develop/medweb/urls.py", line 9, in <module>
from website.views import index, home, login, register, read_verify_code, clinic_problems, \
File "/Users/zhanglei/Develop/medweb/website/views.py", line 13, in <module>
from api.views import alipay_data_process
File "/Users/zhanglei/Develop/medweb/api/views.py", line 26, in <module>
from api.alipay import check_with_rsa_ali, parse_notify_data, decrypt_with_rsa_chunyu
File "/Users/zhanglei/Develop/medweb/api/alipay/__init__.py", line 2, in <module>
from Crypto import Signature
ImportError: No module named Crypto

但是当我在本地环境上安装 pycrypto 时,它可以通过 python 导入。

4

1 回答 1

1

当您使用 sudo 时,它以 root 身份运行并安装在系统目录中。当您在 virtualenv 中时,您想以普通用户身份运行它:

source medweb-env/bin/activate
pip install pycrypto==2.6
于 2013-03-15T03:59:52.740 回答