我使用Python3.7,并遵循virtualenv
和virtualenvwrapper
安装,就像在这篇FreeCodeCamp文章上提到的那样。
对我的.bashrc
文件的更改如下所示:
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# popo edit: Add Python alias
alias python=python3
# popo edit: Step to activate virtualenvs
export WORKON_HOME=$HOME/.virtualenvs
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# SOme more things....
#Virtualenvwrapper settings:
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_VIRTUALENV=/home/pra-dan/.local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh
在.bashrc
的采购上,我得到
/usr/bin/python3: Error while finding module specification for 'virtualenvwrapper.hook_loader' (ModuleNotFoundError: 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 and that PATH is
set properly.
ALthough,我成功地创建了一个环境(idk ),在输入workon
时,我得到了它的名称。
但是现在,当我想要创造一个新的环境,我进入$ mkvirtualenv wrk -p python3
,我得到
ERROR: virtualenvwrapper could not find /home/pra-dan/.local/bin/virtualenv in your path
发布于 2021-01-31 21:16:44
在Ubuntu 18.04上,我有以下几点:
usr/bin/python3: Error while finding module specification for virtualenvwrapper.hook_loader'` (ModuleNotFoundError: No module named virtualenvwrapper`)
virtualenvwrapper.sh: There was a problem running the initialization hooks.
如果Python无法导入模块virtualenvwrapper.hook_loader
,请检查是否已为VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
安装了virtualenvwrapper
并正确设置了路径。
sudo gedit .bashrc
在我的例子中,这就是virtualenvwrapper
设置在.bashrc
中的样子:
export WORKON_HOME=~/.envs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh
我做了以下工作:
sudo apt install python3-pip
sudo pip3 install virtualenv virtualenvwrapper
source ~/.bashrc
这对我有帮助。
发布于 2020-08-28 11:49:26
我认为您忽略了说明中的一个重要说明:在采购virtualenvwrapper.sh之前,出口线必须先来。你要采购两次virtualenvwrapper.sh。
发布于 2020-10-15 10:14:52
中提供的python路径。
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
与安装虚拟化和虚拟包装器的python路径相同。
要找到您的python,可以在控制台中使用which python
或,which python3
命令。
还要验证终端中的python
或python3
命令是否触发了所需版本的python。
https://askubuntu.com/questions/1270747
复制相似问题