Python Virtual Environment

Why create python virtual environment?

Suppose you want to develop more than one python project in your system. Suppose project-1 depending on python3.9 and project-2 depending on python3.10 version. In this situation we need to create virtual environment.

If you create virtual environment then you can easily manage dependencies in your python projects.


How to create python virtual environment in Ubuntu operating system?

Suppose in your Ubuntu operating system python3.10 version already installed but you want to use python3.12 version for your project. First install the python3.12 version in Ubuntu.

Second, create the directory for your project and go to the directory by Ubuntu terminal

Run the command to create virtual environment
$ python3.12 -m venv virtual-directory-name

How to create python virtual environment in Ubuntu operating system?

Active the python virtual environment

Activate the python virtual environment in the Ubuntu.

Command:
$ source env/bin/activate

Active the python virtual environment

env is the python virtual environment directory. (env) before the command you will see automatically after virtual environment is activated.


Check python version after virtual environment is activated

Command:
(virtual-directory) comsysapp:~$ python --version
Or
(virtual-directory) comsysapp:~$ python3 --version
Or
(virtual-directory) comsysapp:~$ python3.12 --version

Python version will be python3.12

Check python version after virtual environment is activated

How to deactivate the python virtual environment


About Us

Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.

Services

Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.


Terms of Use

comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.

Privacy policy

comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.


Sitemap

sitemap

copyright © 2023