In a Django project of mine, I run this command to run the project on localhost:
在我的Django项目中,我运行此命令在localhost上运行项目:
python manage.py runserver
python manage.py runserver
It results in the error:
它导致错误:
Importerror: No module named memcache
Importerror:没有名为memcache的模块
However, I've already fulfilled the requirement via: sudo apt-get install python-memcache
但是,我已经通过以下方式满足了要求:sudo apt-get install python-memcache
Peculiarly, if I go into the python shell outside my virtualevn and try import memcache
, it works fine. However, inside my virtualenv, if I go into the python shell and try import memcache
, I get the same import error listed above. What's going on?
特别是,如果我进入我的virtualevn之外的python shell并尝试导入memcache,它工作正常。但是,在我的virtualenv中,如果我进入python shell并尝试导入memcache,我会得到上面列出的相同导入错误。这是怎么回事?
1 个解决方案
#1
17
As you are using virtualenv
you'd need to install this dependency from inside as you might have created the virtual environment before installed it as a system-wide library.
当您使用virtualenv时,您需要从内部安装此依赖项,因为您可能已经创建了虚拟环境,然后将其作为系统范围的库安装。
From inside your virtualenv
type:
从你的virtualenv类型内部:
pip install python-memcached
This should solves it.
这应该解决它。
#1
17
As you are using virtualenv
you'd need to install this dependency from inside as you might have created the virtual environment before installed it as a system-wide library.
当您使用virtualenv时,您需要从内部安装此依赖项,因为您可能已经创建了虚拟环境,然后将其作为系统范围的库安装。
From inside your virtualenv
type:
从你的virtualenv类型内部:
pip install python-memcached
This should solves it.
这应该解决它。