Use different Python version with virtualenv

后端 未结 30 3268
自闭症患者
自闭症患者 2020-11-21 05:03

I have a Debian system currently running with python 2.5.4. I got virtualenv properly installed, everything is working fine. Is there a possibility that I can use a virtuale

30条回答
  •  余生分开走
    2020-11-21 05:28

    Here is the stepbystep how to create the Virtual environment in Visual Studio Code folder: I used Powershell (Administrator mode):
    1. I create a VSCode folder - "D:\Code_Python_VE" where I want to create Virtual environment.
    2. Next I type the command - "pip3 install virtualenv". (D:\Code_Python_VE> pip3 install virtualenv) 3. D:\Code_Python_VE> python3 -m venv project_env
    4. D:\Code_Python_VE>project_env\Scripts\activate.bat
    5. D:\Code_Python_VE> ls - This will list a new directory "project_env".
    6. D:\Code_Python_VE> code . This will start Visual Studio Code. Make sure the command is (code .).
    7. Create launch.jason with following content:

    {
        // Use IntelliSense to learn about possible attributes.
        // Hover to view descriptions of existing attributes.
        // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
        "version": "0.2.0",
        "configurations": [
            {
                "type": "python",
                "request": "launch",
                "name": "Python: Current File (Integrated Terminal 1)",
                "program": "${file}"
            },
            {
                "name": "Python: Current File (Integrated Terminal 2)",
                "type": "python",
                "request": "launch",
                "program": "${file}",
                "console": "integratedTerminal"
            }
        ]
    }
    

    (Please search how to go to Debug window and Add new Configuration in VS Code).

    1. Press F1 in Visual studio code and the command pallet will open - Select Python Interpreter and select the virtual environment project_env.
    2. Add test.py file with one statement print("Hello World").
    3. Run this program.
    4. In Visual studio Code terminal -
      (project_env) d:\Code_Python_VE>python -m pip install --upgrade
      I hope this helps.

提交回复
热议问题