Search code examples
pythonvirtualenvwrapper

Python Virtual Environment Organization & Management


I work on several projects and tech stacks and Python and ML is just one of them. I have an organization based on the domain that I'm working on. For example., all ML-Prpjects are organized in a folder like this:

/home/me/Projects/ml-projects/...

I'm just starting out with OpenCV and I just came across Python Virtual Environment Wrapper and I used the following script in my bashrc to set it up:

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

This leaves me with the virtual environment located in the .local folder. But how can I attach a virtual environment to my projects within my Project folder? I want my virtual environment folder physically located inside my Projects folder and not cluttered somewhere on the .local folder. Any clues?


Solution

  • Well, Python includes a venv module and you don't really need any wrapper if you just want to create the virtualenv in the current directory

    python -m venv myvenv  # in any directory
    source myvenv/bin/activate