pipenv only works in an activated shell
See original GitHub issueReproducible example:
$ python3 -m venv env
$ env/bin/pip install pipenv
<snip>
$ env/bin/pipenv install pyramid
Creating a Pipfile for this project...
Creating a virtualenv for this project...
Traceback (most recent call last):
File "env/bin/pipenv", line 11, in <module>
load_entry_point('pipenv==4.1.4', 'console_scripts', 'pipenv')()
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 722, in __call__
return self.main(*args, **kwargs)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 697, in main
rv = self.invoke(ctx)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 1066, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 895, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/click/core.py", line 535, in invoke
return callback(*args, **kwargs)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/cli.py", line 801, in install
ensure_project(three=three, python=python)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/cli.py", line 155, in ensure_project
ensure_virtualenv(three=three, python=python)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/cli.py", line 135, in ensure_virtualenv
do_create_virtualenv(three=three, python=python)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/cli.py", line 388, in do_create_virtualenv
c = delegator.run(cmd, block=False)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/delegator.py", line 247, in run
c.run(block=block, binary=binary)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/delegator.py", line 146, in run
s = PopenSpawn(self._popen_args, **pexpect_kwargs)
File "/Users/michael/work/oss/pipenv/env/lib/python3.6/site-packages/pipenv/vendor/pexpect/popen_spawn.py", line 45, in __init__
self.proc = subprocess.Popen(cmd, **kwargs)
File "/Users/michael/.pyenv/versions/3.6.1/lib/python3.6/subprocess.py", line 707, in __init__
restore_signals, start_new_session)
File "/Users/michael/.pyenv/versions/3.6.1/lib/python3.6/subprocess.py", line 1326, in _execute_child
raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'pew'
Expected: A new pipenv virtualenv is created with pyramid installed and the pipfile updated similar to how things work if I run:
$ python3 -m venv env
$ env/bin/pip install pipenv
$ source env/bin/activate
(env) $ pipenv install pyramid
This is a common problem with programs that shell out without activating the virtualenv but it does make things a bit more difficult for people who do not need to activate 99% of the time and prefer being explicit about what python they are using. There are several workarounds but one is to prepend the virtualenv’s bin/scripts folder to the path before shelling out via os.path.join(os.environ('VIRTUAL_ENV'], bin_or_scripts)
.
Issue Analytics
- State:
- Created 6 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
pipenv: only works in a installed folder? - Stack Overflow
To easily activate a virtual environment anywhere with pipenv, ... Yes, Pipenv only works in the directory that the Pipfile is in (or...
Read more >Frequently Encountered Pipenv Problems - Read the Docs
This is usually a result of mixing Pipenv with system packages. We strongly recommend installing Pipenv in an isolated environment. Uninstall all existing ......
Read more >How to Manage your Python Projects with Pipenv and Pyenv
Another important thing to remember is to activate the created virtual environment, which you do by running: pipenv shell.
Read more >Advanced Usage of Pipenv - Python Packaging Authority
Starting in release 2022.3.23 all packages are mapped only to a single package ... To activate this project's virtualenv, run the following: $...
Read more >Python Environment 101 - Towards Data Science
You can activate the project's virtualenv by running pipenv shell , and deactivate it by running exit . pipenv shell to upgrade a...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
As someone who has contributed to pipsi and watches its repo and uses / maintains a fork I can tell you that it’s almost entirely unmaintained… I’m not sure that’s a great installation method to recommend to people. It hasn’t had a release in over 2 years and the
get-pipsi.py
script installs the version from pypi, not the one from the repository. On top of that those installation instructions are currently semi-broken if you don’t have thevirtualenv
command on your path. It’s of course installed into the python that I’m using to run pipenv, but the virtualenv command should again be found relative to the python that’s running, not the system command (similar issue as this one with pew).Note below the usage of
.local/bin/pew
from pipsi. I know it’s hard to get this all isolated when using subprocesses but I maintain that it’s an important thing to do to make a tool that’s easily installable without a bunch of assumptions on the installed environment.pipsi
is able to findvirtualenv
but laterpipenv
/pew
cannot@mmerickel patches welcome!