天天看点

python3·7创建虚拟环境,如何使用python3创建虚拟环境

python3·7创建虚拟环境,如何使用python3创建虚拟环境

I am using python 2.7 + virtualenv version 1.10.1 for running myproject projects. Due to some other projects requirement I have to work with other version of python(Python 3.5) and Django 1.9. For this I have installed python in my user directory. Also I have dowloaded and installed virtualenv( version - 15.1.0) into my user directory.

But whenever I am trying to create virtual env I am getting the below error

python virtualenv/virtualenv.py myproject

Using base prefix '/home/myuser/python3'

New python executable in /home/mount/myuser/project_python3/myproject/bin/python

ERROR: The executable /home/mount/myuser/project_python3/myproject/bin/python is not functioning

ERROR: It thinks sys.prefix is '/home/myuser/python3' (should be '/home/mount/myuser/project_python3/myproject')

ERROR: virtualenv is not compatible with this system or executable

Can anybody tell what I am doing wrong with this

解决方案

In Python 3.6+, the pyvenv module is deprecated. Use the following one-liner instead:

python3 -m venv

This is the recommended way to create virtual environments by the Python community.