1.安装虚拟环境

pip install virtualenv

2.创建项目文件夹,且在该项目下创建虚拟环境(venv文件夹)

mkdir myproject
cd myproject
virtualenv venv

3.virtualenv venv 报错:

Using base prefix ‘/home/260199/anaconda3’
New python executable in /home/260199/FlaskProjects/myproject/venv/bin/python
/home/260199/FlaskProjects/myproject/venv/bin/python: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file: No such file or directory
ERROR: The executable /home/260199/FlaskProjects/myproject/venv/bin/python is not functioning
ERROR: It thinks sys.prefix is ‘/home/260199/FlaskProjects/myproject’ (should be ‘/home/260199/FlaskProjects/myproject/venv’)
ERROR: virtualenv is not compatible with this system or executable

经网上搜索后发现,使用的是anaconda python

卸载:pip uninstall virtualenv
使用conda安装:conda install virtualenv

即可正常使用virtualenv

备注:conda自己即可创建虚拟环境

conda create -n your_env_name python=X.X(2.7、3.6等)

your_env_name为自己起名的虚拟环境,your_env_name文件可以在Anaconda安装目录envs文件下找到。在不指定python版本时,自动安装最新python版本。
详细说明可参考链接:https://www.cnblogs.com/yuehouse/p/10239195.html (以后详细研究)

文章来源于互联网,如有雷同请联系站长删除:linux 虚拟环境virtualenv安装(报错及报错后的正确安装)

发表评论