简体   繁体   English

如何使用特定下载的 python 版本创建 virtualenv

[英]How to create virtualenv with specific downloaded python version

I know there are some similar questions,but it is really hard for me to finish it.我知道有一些类似的问题,但我真的很难完成它。

I'm trying to create a virtualenv with python 3.7.7 in windows.我正在尝试在 windows 中使用 python 3.7.7 创建一个 virtualenv。

I have a downloaded python 3.7.7我有一个下载的 python 3.7.7

C:\Users\willi\AppData\Local\Programs\Python\python-3.7.8-embed-amd64

Since I can built a virtualenv using:因为我可以使用以下方法构建 virtualenv:

python3 -m venv myenv

So I tried to modify it,so that it can match specific python version:所以我尝试对其进行修改,使其可以匹配特定的 python 版本:

python3 -m C:\Users\willi\AppData\Local\Programs\Python\python-3.7.8-embed-amd64\python.exe myenv

But it failed:但它失败了:

ModuleNotFoundError: No module named 'C:\\Users\\willi\\AppData\\Local\\Programs\\Python\\python-3')

Any friends can teach me how to build a virtualenv with python 3.7.7?有朋友可以教我如何用 python 3.7.7 构建一个虚拟环境吗?

I think you haven't installed virtual environment in your local python我认为您尚未在本地 python 中安装虚拟环境

pip install virtualenv

and follow your steps.并按照你的步骤。 Stil, find the error.仍然,找出错误。 Try doing below methods, I think you will get your answer-试试下面的方法,我想你会得到你的答案-

in command prompt在命令提示符下

pip install virtualenv

go to the location, where you want to create your environment go 到您要创建环境的位置

cd location
virtualenv project_env_name

Now, you will find a python env in the desired location, Then go to scripts现在,您将在所需位置找到 python 环境,然后将 go 写入脚本

cd project_env_name/scripts
activate

You will enter the environment you created.您将进入您创建的环境。 while leaving the environment, do离开环境时,做

deactivate

To leave the environment.离开环境。

This method works if you want to create the same python version environment as python version in your machine.如果您想在您的机器中创建与 python 版本相同的 python 版本环境,则此方法有效。 If you want to create an environment of the different version, you need to install the python of that version.如果要创建不同版本的环境,需要安装该版本的python。

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

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