mkvirtualenv django_env -p python3
会遇到一些问题,
1.
首先需要安装
1.
升级
python
包管理工具
pip
pip install --upgrade pip
备注:当你想升级一个包的时候
`pip install --upgrade
包名
`
2.python
虚拟环境安装
sudo apt-get install python-virtualenv
sudo easy_install virtualenvwrapper
命令输入:
mkvirtualenv
报错:
bash: mkvirtualenv:
未找到命令,需要执行以下环境变量设置。
1.
创建目录用来存放虚拟环境
mkdir $HOME/.virtualenvs
2.
在
~/.bashrc
中添加行:
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
3.
运行
:
source ~/.bashrc
报错
/usr/bin/python: 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/python and that PATH is
set properly.
解决办法:
sudo vim ~/.bashrc
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh
4.
mkvirtualenv django_env -p python3
报错
PermissionError: [Errno 13] Permission denied: ‘/home/shizhifeng/.virtualenvs/django_env‘
解决:使用虚拟环境
virtualenv
创建虚拟环境出现
PermissionError: [Errno 13] Permission denied:
原因:虚拟环境安装的目录所属用户非当前用户
解决办法:将目录及其文件的所有者改为当前用户
当前用户查看命令:
whoami
解决命令:
sudo chown -R
当前用户
待更改用户的目录
/
实例:
sudo chown -R shizhifeng /home/shizhifeng/.virtualenvs/
https://easydoc.xyz/#/p/43577971
https://www.jianshu.com/p/dbb92ba83fb1
https://www.cnblogs.com/xiaoyaojinzhazhadehangcheng/p/7977218.html supervsoird
https://blog.csdn.net/sinat_41622641/article/details/81636682
https://github.com/marcgibbons/django-rest-swagger/issues/547
原文地址:https://www.cnblogs.com/yichuncom/p/11385783.html
时间: 2024-10-03 01:02:59