[VMware+Ubuntu+VSCode] Configure python virtual environment

1、Install VMware+Ubuntu

Eight minutes to complete VMware and ubuntu system installation

This video is more clear

2. Install VScode

VScode is free, just go to Ubuntu Software to search for VSCode and download it

Here I directly use apt to download and install:

1.添加微软公钥
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -

2、安装依赖文件
sudo apt install software-properties-common apt-transport-https wget

3、将vscode的apt源添加到到本地
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"

4、安装vscode
sudo apt update 
sudo apt install code

Open the application, vscode has been installed:
insert image description here

You can watch this video: [Linux Pit Guide] Save your old computer! Issue 4: Installing Applications | deb | apt | snap

3. Configure VSCode

Directly expand and enter Chinese and python on the left to install these two basic packages:
insert image description here

After installing these two, you can basically start writing python programs

4. Configure the virtual environment

But what I just installed is only the global environment, and I generally don't install anything in the global environment. I will create a virtual environment myself:

1、home文件下新建一个envs文件夹,用来存放新建的环境

2、cd envs

3、sudo apt install python3.8-venv

4、python -m venv learn_py

At this point, the new environment has been successfully established. Verify it:

cd learn_py/bin/
source activate

success!
insert image description here

5. Use a new virtual environment in VSCode

Click the version of the python interpreter in the lower right corner of the software, enter the interpreter path, find the location of the newly created interpreter, find your own python interpreter in the bin directory, and that's it.
insert image description here
insert image description here

insert image description here

Reference

[Linux Pit Guide] Save your old computer! Issue 4: Installing Applications | deb | apt | snap

Guess you like

Origin blog.csdn.net/qq_38253797/article/details/127244720