Pipenv global environment

↘锁芯ラ 提交于 2019-12-10 10:06:58

问题


Pipenv is a good tool for managing python environments. But some things need to be global. For instance most command line tools should be always available and jupyter for use with non python kernels.

Can pipenv be used to manage such a global python environment as well? If so, how? Is this a sane thing to do?


回答1:


Installing from Pipenv without a virtual environment

I had a similar problem to you - I needed to install dependencies globally on our production server.

I came across this discussion which alerted me to the --system option. pipenv install --system installs dependencies globally.

Installing only some dependencies globally

There are a couple of other aspects of your question which I thought I should address too:

First of all, you talk about "some" things being global. If you have some dependencies which need to be global and some which need to be in a virtual environment, you could split them into separate Pipfiles and use the PIPENV_PIPFILE environment variable. For example:

# Install your global deps from a separate file
$ PIPENV_PIPFILE="/path/to/global/deps/Pipfile" pipenv install --system

# Use your local Pipfile for the project-specific deps (in a virtual environment as normal)
$ pipenv install

An alternative: pipsi

Secondly, you ask "is this a sane thing to do?" I think is is sane to use Pipenv for global dependencies in general, but for your use case of command-line tools, I would use pipsi. Pipsi installs libraries globally but isolated from each other (see the link for more details). However, I don't think it offers a way of using a requirements file (ref).

For some general reading about Python setup and dependencies, I really recommend Jacob Kaplan-Moss's article My Python Development Environment, 2018 Edition.



来源:https://stackoverflow.com/questions/51554241/pipenv-global-environment

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!