Skip to content

maudzung/virtual_environment_python3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

The instruction to setup a virtual environment

We usually work on different projects with different libraries, even with different versions of same libraries. Therefore, we should use virtual environments.
Each project works on a specific virtual environment.

Set execute permission to setup.sh, then run it

chmod +x setup.sh
./setup.sh

Add the below lines to ~/.profile

# virtualenv and virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source /usr/local/bin/virtualenvwrapper.sh

similarly, add these lines to ~/.bashrc

export WORKON_HOME=~/.virtualenvs
VIRTUALENVWRAPPER_PYTHON='/usr/bin/python3'
source /usr/local/bin/virtualenvwrapper.sh

Execute these commands:

source ~/.profile
source ~/.bashrc

Now, we're going to create a virtual environment:

mkvirtualenv imrc -p python3

(imrc is the name of your environment)

To work on the new environment, execute the command:

workon imrc

Now, you are in the virtual environment named imrc, you should install essential libraries in the environment for our work. The libraries are listed in the requirement.txt file, you can modify (add/delete) libraries that you don't need to use.
Obviously, you can install any libraries whenever you want. Run the command to install libraries listed in the requirement.txt:

pip install -r requirement.txt

Now, you can work with the essential libs. To check the libraries that are installed in your environment, run:

pip list

Thank you.

About

The instruction to setup a virtual environment

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages