Ani*_*ish 28 python django virtualenv python-3.x
我使用python 2.7 + virtualenv版本1.10.1来运行myproject项目.由于一些其他项目的要求,我必须使用其他版本的python(Python 3.5)和Django 1.9.为此我在我的用户目录中安装了python.此外,我已经下载并将virtualenv(版本 - 15.1.0)安装到我的用户目录中.但每当我尝试创建虚拟环境时,我都会收到以下错误
python virtualenv/virtualenv.py myproject
Run Code Online (Sandbox Code Playgroud)
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
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我这件事我做错了什么
The*_*inn 59
在Python 3.6+中,不推荐使用pyvenv模块.请改用以下单线:
python3 -m venv <myenvname>
Run Code Online (Sandbox Code Playgroud)
这是Python社区创建虚拟环境的推荐方法.
创建虚拟环境
virtualenv -p python3 venv_name
Run Code Online (Sandbox Code Playgroud)
这将在 baseDirectory/bin/python3 中创建新的 python 可执行文件
如何激活新创建的 Venv:
cd baseDirectory/bin/
source activate
Run Code Online (Sandbox Code Playgroud)
停用新的 venv
deactivate
Run Code Online (Sandbox Code Playgroud)
小智 6
venv从版本3.3 开始,Python已经内置了"virtualenv" .您不再需要安装或下载virtualenvPython 3.3+ 的脚本.
https://docs.python.org/3/library/venv.html
检查您的安装是否提供了pyvenv应该负责创建"virtualenv"的命令.参数类似于经典的virtualenv项目.
$ pyvenv --help
usage: venv [-h] [--system-site-packages] [--symlinks | --copies] [--clear]
[--upgrade] [--without-pip]
ENV_DIR [ENV_DIR ...]
Creates virtual Python environments in one or more target directories.
positional arguments:
ENV_DIR A directory to create the environment in.
optional arguments:
-h, --help show this help message and exit
--system-site-packages
Give the virtual environment access to the system
site-packages dir.
--symlinks Try to use symlinks rather than copies, when symlinks
are not the default for the platform.
--copies Try to use copies rather than symlinks, even when
symlinks are the default for the platform.
--clear Delete the contents of the environment directory if it
already exists, before environment creation.
--upgrade Upgrade the environment directory to use this version
of Python, assuming Python has been upgraded in-place.
--without-pip Skips installing or upgrading pip in the virtual
environment (pip is bootstrapped by default)
Once an environment has been created, you may wish to activate it, e.g. by
sourcing an activate script in its bin directory.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
32657 次 |
| 最近记录: |