Skip to main content

Posts

Showing posts with the label virtualenv

Sharing a virtualenv across several Python projects using Pipenv

There is a standard library for all projects in Python. However, several projects don’t always have the same dependencies all the time. That is where virtual environments come to play.

You can follow this official document to use two separated tools virtualenv and pip to fulfill that need. My preferred alternative is to use pipenv. Pipenv is easy to use and convenient. The following are my steps to make a shared virtualenv for my all projects which requires the same dependencies.

Step 1. Create an isolated virtualenv.
python -m venv my-shared-env Step 2. Create a symbolic link to the created virtualenv.
cd project_1 ln -s ~/.local/share/virtualenvs/my-shared-env .venv I have encountered the following issue at step 1.
FileNotFoundError: [Errno 2] No such file or directory: '{my_project_path}/.venv/bin/pip': '{my_project_path}/.venv/bin/pip' The root cause was I tried to create virtualenv by running pipenv install and renaming the generated virtualenv to a new name but …