![]() because it now doesn't use your system site-packages. You should see a lot of /home/user/.virtualenv/. ![]() ![]() Also if you now run python -c "import sys print sys.path" ![]() You will see that the environment will be set up, and your prompt now includes the name of your active environment in parentheses. The -p argument is optional, it is used to set the Python version to use it can also be python3 for example. Now we create our first virtual environment. Source ~/.bashrc to load the changes source ~/.bashrc We can also add some extra tricks like the following, which makes sure that if pip creates an extra virtual environment, it is also placed in our WORKON_HOME directory: echo "export PIP_VIRTUALENV_BASE=$WORKON_HOME" > ~/.bashrc Now also create this directory mkdir $WORKON_HOMEĪnd put this export in our ~/.bashrc file so this variable gets automatically defined echo "export WORKON_HOME=$WORKON_HOME" > ~/.bashrc Let's make this ~/.virtualenvs export WORKON_HOME=~/.virtualenvs bashrc echo "source ~/.local/bin/virtualenvwrapper.sh" > ~/.bashrcįirst we export the WORKON_HOME variable which contains the directory in which our virtual environments are to be stored. Optional (but recommended): Turn on bash autocomplete for pipīecause we want to avoid sudo pip we install virtualenvwrapper locally (by default under ~/.local) with: pip install -user virtualenvwrapperĪnd echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3" > ~/.bashrc (if you use Python 3, you may need to use pip3 instead of pip in the rest of this guide). Or for Python 3 sudo apt install python3-pip Install pip for Python 2 with sudo apt install python-pip Then run echo "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh" > ~/.bashrc There are two ways to install virtualenvwrapper: As Ubuntu package (from Ubuntu 16.04) The reason we are also installing virtualenvwrapper is because it offers nice and simple commands to manage your virtual environments. Install virtualenv with sudo apt install virtualenv ![]() With virtualenvwrapper (user friendly wrappers for the functionality of virtualenv) Install virtualenv ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
February 2023
Categories |