How to generate Python virtual environment in Ubuntu

Shuanglin Li
2024-03-22 / 0 评论 / 40 阅读 / 正在检测是否收录...

When you want to do something by Python in Ubuntu, once you using the pip install module_name to install the package, you would meet you have no right to use pip install.

Therefore, you should use the venv tools to generate a virtual environment. the full command is

python3 -m venv venv_folder_name

The result as show in Figure 1.

e7c9dde8-1b47-4ec3-91e5-f2fd0dc8bdfe.png
Figure 1. The sample of how to generate virtual environment in Ubuntu on vs code

After that, the venv_folder_name will be generated in your workspace, then you should to activate this folder, the command line is present following.

source venv_folder_name/bin/activate

Then you can use pip install module_name to install the packages.

本文共 0 个字数,平均阅读时长 ≈ 0分钟
0

打赏

海报

正在生成.....

评论 (0)

取消