Configuring Python Virtual Environment to use Python 3

前端 未结 4 606
北荒
北荒 2021-01-17 06:01

I am learning Django. I installed two different versions of python on my laptop, 2 and 3. I configured my Laptop to use Python 3, so when I check version using the command l

相关标签:
4条回答
  • 2021-01-17 06:31

    If you want to use Python 3, the recommended way to create a virtual environment is using python3 -m venv as follows:

    python3 -m venv venv # this will create a virtual environment called venv
    

    In your case, you can directly use python instead of python3 since you have already configured your laptop to use Python 3 when running python (this is shown in your question).

    In Windows, to activate this virtual environment run the following:

    venv\Scripts\activate.bat
    

    That's it!

    0 讨论(0)
  • 2021-01-17 06:34

    If you are on Linux just use the command python3 -m venv myvenv in the directory of your project and you're done!

    0 讨论(0)
  • 2021-01-17 06:44

    Virtualenv with python 2

    virtualenv myEnv
    

    Virtualenv with python 3

    virtualenv -p python3 myEnv
    
    0 讨论(0)
  • 2021-01-17 06:52

    Execute below command line:->

    For Python3 :->

    virtualenv --python = $(which python3) EnvironmentName
    

    For Python2 :->

    virtualenv --python = $(which python) EnvironmentName
    
    0 讨论(0)
提交回复
热议问题