Pipenv seems to work only in the directory where the Pipfile lives. Maybe I'm trying to use it in a way it is not designed for.
For example, I installed a tool called "leo" (an editor) and no surprise that I will go to many folders and start pipenv run Leo
and it will start to install another virtual environment. What's the workaround?
While pip can install Python packages, Pipenv is recommended as it's a higher-level tool that simplifies dependency management for common use cases. This does a user installation to prevent breaking any system-wide packages.
pipenv stores all the virtual environments it creates in one place, which is a hidden directory in your home directory by default.
TL;DR. pipenv creates isolated pip environments whereas pyenv+virtualenv creates virtualenvs that multiple projects can use.
pipenv. pipenv- like venv - can be used to create virtual envelopes but additionally rolls-in package management and vulnerability checking functionality. Instead of using requirements. txt , pipenv delivers package management via Pipfile.
You can run pew
from any directory:
# install pew using pip (not pipenv)
$ pip install pew
...
# get venv name
$ (cd <folder with Pipfile> && pipenv --venv)
<some path>/python-1234ABCD
# activate venv
$ pew workon python-1234ABCD
# run pipenv as usual
$ pipenv run leo
As far as I understand it, you can only execute commands like running a text editor with pipenv if you are currently already running a virtual environment with pipenv. If not, it will make a new virtual env in the current directory and then run the command in it.
The result of pipenv --help
says, for the run command:
run Spawns a command installed into the virtualenv.
At the directory where Pipfile resides, do
pipenv --venv
This will show the path where the virtual env is located. Copy that path, such as /Users/yourname/.local/share/virtualenvs/yourproject-8XhejQjj
, and at any other folder you can activate the venv with source
, e.g.:
source /Users/yourname/.local/share/virtualenvs/yourproject-8XhejQjj/bin/activate
This is covered by Ken Reitz's 2018 PyData talk.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With