[英]ERROR: virtualenvwrapper could not find virtualenv in your path
I'm trying to create a virtualenv with virtualenvwrapper
, but when I use mkvirtualenv
I get the following :我正在尝试使用
virtualenvwrapper
创建一个 virtualenv ,但是当我使用mkvirtualenv
我得到以下信息:
ERROR: virtualenvwrapper could not find virtualenv in your path
I assumed it was a PYTHONPATH problem.我认为这是PYTHONPATH问题。 But if I do a
pip show virtualenv
I get the following :但是,如果我执行
pip show virtualenv
则会得到以下信息:
---
Metadata-Version: 2.0
Name: virtualenv
Version: 13.1.0
Summary: Virtual Python Environment builder
Home-page: https://virtualenv.pypa.io/
Author: Jannis Leidel, Carl Meyer and Brian Rosner
Author-email: python-virtualenv@groups.google.com
License: MIT
Location: /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages
Requires:
And here is my PYTHONPATH :这是我的PYTHONPATH :
/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages:/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages:~/.brew/Cellar /nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/bin:/nfs/zfs -student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages:/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/ lib/python/site-packages:~/.brew/Cellar
It contains the directory containing virtualenv!它包含包含 virtualenv 的目录!
(ie : /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages ) (即: /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages )
My ~/.zshrc contains :我的~/.zshrc包含:
export WORKON_HOME=~/Envs
export PROJECT_HOME=$HOME/Devel
source $HOME"/Library/Python/2.7/bin/virtualenvwrapper.sh"
EDIT : virtualenvwrapper.sh is written in bash, perhaps should I check my PATH instead of my PYTHONPATH ?编辑: virtualenvwrapper.sh 是用 bash 编写的,也许我应该检查我的PATH而不是我的PYTHONPATH ?
So, what could the problem be?那么,问题可能是什么? How could I fix it?
我怎么能修好呢?
Thank you in advance for your help.预先感谢您的帮助。
Re-installling virtualenv fixed my problem.重新安装 virtualenv 解决了我的问题。
I had the same issue.我遇到过同样的问题。
$ mkvirtualenv mysite
ERROR: virtualenvwrapper could not find virtualenv in your path
After a lot of time consuming efforts, I decided to re-install virtualenv.经过大量耗时的努力,我决定重新安装virtualenv。
sudo apt install virtualenv
This fixed my issues.这解决了我的问题。 I already had virtualenv installed.
我已经安装了 virtualenv。 But I think it got broken or met with some errors.
但我认为它坏了或遇到了一些错误。
I am using python3 with virtualenvwrapper installed on Ubuntu 18.04, using pip3 without sudo.我在 Ubuntu 18.04 上使用安装了 virtualenvwrapper 的 python3,使用没有 sudo 的 pip3。 If you are in this situation, you might find interesting my configuration.
如果您处于这种情况,您可能会发现我的配置很有趣。
In the end of my .bashrc I added the following rows (remember to put your username in the YOUR_USERNAME field):在我的 .bashrc 的末尾,我添加了以下行(记住将您的用户名放在 YOUR_USERNAME 字段中):
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/YOUR_USERNAME/.local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
Then restart the cli with ctrl-D ctrl-T or reload the config with source ~/.bashrc
.然后使用 ctrl-D ctrl-T 重新启动 cli 或使用
source ~/.bashrc
重新加载配置。 Then you should be good to go!那么你应该很高兴去! Try the installation with:
尝试安装:
lsvirtualenv
mkvirtualenv test
workon test
deactivate
rmvirtualenv test
If you could create and delete a virtual environment, you are ready to go.如果您可以创建和删除虚拟环境,那么您就可以开始了。
sudo find / -name "virtualenv"
Then I find the executable file path is:然后我发现可执行文件路径是:
/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/virtualenv
/usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/virtualenv
Touch a soft link in the /usr/local/bin/
directory or add the path to .bash_profile
, I prefer the former:触摸
/usr/local/bin/
目录中的软链接或将路径添加到.bash_profile
,我更喜欢前者:
sudo ln -s /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/bin/virtualenv /usr/local/bin/virtualenv
I finally found out what the problem was :我终于发现了问题所在:
virtualenvwrapper.sh is written in BASH and not in Python . virtualenvwrapper.sh是用BASH编写的,而不是用Python编写的。 So virtualenv is called from a shell ( zsh ).
所以virtualenv是从 shell ( zsh ) 调用的。 I didn't have to bother about my PYTHONPATH , but about my PATH (I was already able to import virtualenv from my python shell anyway).
我不必担心我的PYTHONPATH ,而是我的PATH (无论如何我已经能够从我的 python shell 中导入 virtualenv )。
I just added the correct directory to my PATH and everything worked fine (the directory containing the virtualenv
executable, ie /Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages
which isn't included in my PATH
by default despite being the directory virtualenv
and other pip-installed tools was in).我刚刚将正确的目录添加到我的PATH并且一切正常(包含
virtualenv
可执行文件的目录,即/Volumes/Data/nfs/zfs-student-3/users/2013_paris/vmonteco/Library/Python/2.7/lib/python/site-packages
默认情况下不包含在我的PATH
,尽管目录virtualenv
和其他 pip 安装的工具在)。
virtualenvwrapper
located.virtualenvwrapper
所在的位置。 in my case ~/.local/bin
May be it's installed in可能是安装在
/usr/local/bin/
It totally depends on the System or Package Manager you are using.这完全取决于您使用的系统或包管理器。
.bashrc
or .zshrc
or whatever by simply.bashrc
或.zshrc
或其他任何内容中PATH=$PATH:<directory_you_want_to_add>
for example例如
PATH=$PATH:~/.local/bin
Also add the following configuration in .bashrc
or .zshrc
同时在
.bashrc
或.zshrc
添加以下配置
# the path you want your virtual environments to be saved and loaded from
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/<project_folder>
# most important, this is the program which loads virtualenv
# please update the path where virtualenvwrapper.sh is located
source /usr/local/bin/virtualenvwrapper.sh
Don't Forget to restart the shell.. or reload the configuration...不要忘记重新启动shell .. 或重新加载配置...
To test whether it worked测试它是否有效
mkvirtualenv test
if you see a test environment created then everything is ok.如果您看到创建了一个测试环境,则一切正常。
For Detailed Installation Instructions go to the docs:virtualenvwrapper installation有关详细的安装说明,请转到文档:virtualenvwrapper 安装
In my case, I tested use this command:在我的情况下,我测试使用这个命令:
sudo find / -name "virtualenv"
and I have a list with all path to this file,我有一个包含此文件所有路径的列表,
I tested one to one and solved with path:我一对一测试并用路径解决:
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
My configurations to environment variables is :我对环境变量的配置是:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenv
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh
in file .bashrc.
在文件
.bashrc.
Now all its works.现在它的所有作品。
ERROR: virtualenvwrapper could not find virtualenv in your path
This error means - program virtualenv
is not in your system path.此错误意味着 - 程序
virtualenv
不在您的系统路径中。 This mostly happens if you install virtualenv
via pip without sudo.如果您在没有 sudo 的情况下通过 pip 安装
virtualenv
,这通常会发生。 This kind of installation stores data in users local directory eg ~/.local/bin
.这种安装将数据存储在用户本地目录中,
eg ~/.local/bin
。 So first step is to find where this binary present.所以第一步是找到这个二进制文件的位置。 You can do that using
locate
program.您可以使用
locate
程序来做到这一点。 First update its database using sudo updatedb
.首先使用
sudo updatedb
更新其数据库。 Then run locate *bin/virtualenv
.然后运行
locate *bin/virtualenv
。 Whatever path you get, append it in system path variable.无论您获得什么路径,都将其附加到系统路径变量中。 This you can do by adding below line in your shell config file eg
~/.bashrc or ~/.zshenv
.这可以通过在 shell 配置文件中添加以下行来完成,例如
~/.bashrc or ~/.zshenv
。
export PATH=$PATH:/your/path
eg例如
export PATH=$PATH:~/.local/bin
Now open new shell and try again.现在打开新外壳并重试。 Error should be gone.
错误应该消失了。
For me it was:对我来说是:
export PYTHONPATH=/usr/bin/python3
export PATH=$HOME/.local/bin:$PATH
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh
I changed the line to:我将行更改为:
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv
It worked.有效。
The way I did it was (using zsh) in this way:我这样做的方式是(使用 zsh)以这种方式:
export PATH=$HOME/bin:/usr/local/bin:$PATH:/Users/username/Library/Python/2.7/bin:$PATH
I simply located the file of virtualenvwrapper.sh inside this path /Users/username/Library/Python/2.7/bin:$PATH
我只是在这个路径
/Users/username/Library/Python/2.7/bin:$PATH
了 virtualenvwrapper.sh 的文件
and added that path to PATH.并将该路径添加到 PATH。
Your PYTHONPATH makes me think you have Homebrew installed.你的 PYTHONPATH 让我觉得你安装了 Homebrew。 It sounds like virtualenvwrapper was installed with either your system pip or your homebrew pip while it is being executed with the opposite python interpreter.
听起来 virtualenvwrapper 是与您的系统 pip 或自制程序 pip 一起安装的,而它正在使用相反的 python 解释器执行。
I had this same issues and tried many many things, what found as a solution is i had three pip version, pip with 2.7, 3.6 and 3.7.我遇到了同样的问题并尝试了很多东西,找到的解决方案是我有三个 pip 版本,2.7、3.6 和 3.7 的 pip。 and 3.6 was the one works fine for many things, and install as
sudo pip3.6 install virtualenv
, and it works fine.和 3.6 是一个在很多事情上都可以正常工作的,并且安装为
sudo pip3.6 install virtualenv
,它工作正常。 I would suggest, check your pip version and tried to install based on your pip ver.我建议,检查您的 pip 版本并尝试根据您的 pip 版本进行安装。
I have set the variable VIRTUALENVWRAPPER_VIRTUALENV
in my .zshrc to the full path of the virtualenv
binary and it works for me.我已经设置了可变
VIRTUALENVWRAPPER_VIRTUALENV
在我的.zshrc到的完整路径virtualenv
二进制文件,它为我工作。
Here is my .zshrc file:这是我的.zshrc文件:
export WORKON_HOME=$HOME/.virtualenvs
export PROJECT_HOME=$HOME/Devel
export VIRTUALENVWRAPPER_VIRTUALENV=$HOME/Library/Python/2.7/bin/virtualenv
source $HOME/Library/Python/2.7/bin/virtualenvwrapper.sh
删除所有与 virtualenv 相关的包会起作用。
pip freeze -l | grep ^virtualenv | awk -F= '{print $1}' | xargs pip uninstall -y
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.