简体   繁体   English

如何使用 Python 3 创建 Virtualenv?

[英]How to create a Virtualenv with Python 3?

I have a problem with Linux in PC.我在 PC 上使用 Linux 时遇到问题。 I installed python3.8.我安装了python3.8。 I want work with python 3. When I create a virtualenv file it gets created with python2, but I don't want work with python2.我想使用 python 3。当我创建一个 virtualenv 文件时,它是用 python2 创建的,但我不想使用 python2。 How can I enable python2?如何启用python2?

您可以在使用-p标志创建新虚拟环境时设置 python 版本。

virtualenv -p python3.8 my-env-name

Perhaps you can try to locate the location of the python version you want to use the interpreter of (eg. get its path through which python3 ).也许您可以尝试定位要使用其解释器的 python 版本的位置(例如,通过which python3获取其路径)。 Once obtained the path you can create the enviroment specifying the location of the interpreter you want to use for that virtual environment virtualenv -p /usr/bin/python3.6 venv获得路径后,您可以创建环境,指定要用于该虚拟环境的解释器的位置virtualenv -p /usr/bin/python3.6 venv

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM