当存在 python 2.7 时,使用 python 3.8 创建虚拟环境 [英] Creating Virtual environment using python 3.8 when python 2.7 is present

查看:146
本文介绍了当存在 python 2.7 时,使用 python 3.8 创建虚拟环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在 Windows 中使用 mkvirtualenv 和 python 3 创建一个虚拟环境,但环境是用 python 2.7 创建的.我的 pip 版本也来自 python 2.7,我避免使用

I am trying to create a virtual environment using mkvirtualenv with python 3 in Windows but the environment is created with python 2.7.My pip version is also from python 2.7 which i have avoided using

py -m pip install virtualenvwrapper-win

当我这样做

mkvirtualenv test

环境是用 python 2.7 创建的请帮我解决提前致谢:)

environment is created with python 2.7 Please help me with a solution Thanks in advance:)

推荐答案

如果你想创建一个带有 python 3.X 版本的 virtualenv,2.X

If you would like to create a virtualenv with python 3.X having the version 2.X

你只需要为你的虚拟环境传递一个参数.

You just have to pass a parameter argument for your virtual env.

$ virtualenv venv -p $(which python3)

此命令将指向您当前的 python3 安装文件夹,并创建一个从您当前的 python3 二进制文件复制的 virtualenv.

This command will point to your current python3 install folder, and create a virtualenv copied from your current python3 binaries.

如果你想看看这个命令是做什么的,只需启动命令:

If you would like to see what this command does, just fire the command:

$ which python3
#should print your current python3 binary folder.

这篇关于当存在 python 2.7 时,使用 python 3.8 创建虚拟环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆