Pipenv allows the use of the system Python instead of creating a virtualenv to install packages:
$ pipenv install --system
But if I do so, subsequent pipenv run
s are trying to create the virtualenv instead of using the system Python. In particular, I'm interested in using Pipenv scripts:
$ pipenv run postinstall
Creating a virtualenv for this project...
Is there a way to use the system Python interpreter for Pipenv scripts?
As far as I'm aware, it's not possible do run the scripts inside the Pipfile
with pipenv
if you don't use any
The maintainers of pipenv
decided against such a feature a couple years ago (e.g. see the discussion at Add a --system flag to pipenv run #2693), and I can't find anything newer that would say otherwise.
If you want to run a script in your system installation, just run it normally in the terminal. If you work without a virtual environment, you don't need pipenv
to run any scripts. E.g. if you have defined app = "uvicorn my_app.main:app --port 8080"
in the script
section and make a system installation, you can afterwards just call uvicorn my_app.main:app --port 8080
in the terminal.
I understand that there is some convenience to define some scripts/aliases in the Pipfile
. But if you need those also outside virtual environments, it would be better to just create actual shell scripts. And if you want to have the pipenv run
functionality to keep working, just make sure that these scripts defined in the Pipfile
call the shell scripts in order to avoid code duplication.