没有名为"virtualenvwrapper"的模块 [英] No module named 'virtualenvwrapper'

查看:128
本文介绍了没有名为"virtualenvwrapper"的模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ubuntu 14.04 LTS实例在Amazon EC2上设置Django项目.我想使用Python 3编写代码.我被告知最好的方法是使用virtualenvwrapper.我已经成功安装virtualenvwrapper并放入

I am working to set up a Django project on Amazon EC2 with an Ubuntu 14.04 LTS instance. I want to write my code using Python 3. I've been advised that the best way to do this is to use virtualenvwrapper. I've installed virtualenvwrapper successfully and put

export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.4
export PROJECT_HOME=$HOME/Devel
source /usr/local/bin/virtualenvwrapper.sh

进入我的.bashrc文件.现在我看到了:

into my .bashrc file. Now I see:

 /usr/bin/python3.4: Error while finding spec for 'virtualenvwrapper.hook_loader' (<class 'ImportErro
 r'>: No module named 'virtualenvwrapper')
 virtualenvwrapper.sh: There was a problem running the initialization hooks.     

 If Python could not import the module virtualenvwrapper.hook_loader,
 check that virtualenvwrapper has been installed for
 VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3.4 and that PATH is
 set properly.

我该如何解决?

推荐答案

除了使用-p标志指定其他python解释器外,您还可以将所需的解释器配置为默认.

Instead of specifying a different python interpreter with -p flag, you can also config your desired interpreter as default.

根据virtualenvwrapper文档virtualenvwrapper.sh查找第一个python,然后$PATH上的virtualenv程序,并记住它们供以后使用.

According to virtualenvwrapper's documentation, virtualenvwrapper.sh finds the first python and virtualenv programs on the $PATH and remembers them to use later.

如果您的操作系统的默认python解释器(/usr/bin/python)上未安装virtualenvwrapper,请确保您按以下方式覆盖环境变量:

If your virtualenvwrapper is not installed on your OS's default python interpreter (/usr/bin/python), make sure you override the environment variables as below:

  • VIRTUALENVWRAPPER_PYTHON到python解释器的完整路径
  • VIRTUALENVWRAPPER_VIRTUALENV到virtualenv的完整路径
  • VIRTUALENVWRAPPER_PYTHON to the full path of your python interpreter
  • VIRTUALENVWRAPPER_VIRTUALENV to the full path of the virtualenv

例如,在我的.bash_profile(Mac)上:

For example, on my .bash_profile (Mac):

#virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/Library/Frameworks/Python.framework/Versions/3.5/bin/virtualenv
source /Library/Frameworks/Python.framework/Versions/3.5/bin/virtualenvwrapper.sh

通过运行source ~/.bash_profile

这篇关于没有名为"virtualenvwrapper"的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆