Creating Virtual environment using python 3.8 when python 2.7 is present

时间秒杀一切 提交于 2021-02-09 01:55:34

问题


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

When i do

mkvirtualenv test

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


回答1:


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)

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.



回答2:


you need install python3.8 to your enviroment, if you are in ubuntu(18.04):

sudo apt install python3.8

and:

mkvirtualenv name_of_the_project -p python3.8



回答3:


Does:

python3 -m venv venv

solve your problem?



来源:https://stackoverflow.com/questions/61908834/creating-virtual-environment-using-python-3-8-when-python-2-7-is-present

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!