by antihero · 14y ago · 0 comments
Basically, you should never ever find yourself typing sudo pip. If you refuse to use a virtualenv for some reason, use pip --user.
The other benefit of this approach is that your system package manager will keep your system packages up to date and the required versions for any software on your system.
Honestly, I think the best solution in the long term would be for pip, by default, to install to a user environment (installing in ~/.local using the --user flag) if it is run unprivileged and not in a virtualenv.
- Never run pip outside of a virtualenv. I prefer to use virtualenv directly so that I have everything contained in my working directory, but virtualenvwrapper is fine too.
- Never install system-wide Python packages directly. Okay, I'm exaggerating, but I don't think I've ever needed a system-wide Python package as anything more than a dependency - and in the rare case when I have, the AUR (in my case) makes it easy to wrap a setup.py file inside a 'system' package.
The only problem with this workflow is that I still haven't figured out how to change the IPython module path, so when I run IPython inside a working directory with a virtualenv activated, I access the system packages, not the locally-installed ones. I could pip install IPython, but that'd add a completely unnecessary dependency to every project. Does anybody know an easy way to switch the path for IPython via command line switch, etc.?
My major problem I have is packages using cython or depending on external C header files in some other way. For example, matplotlib and the IPython qtconsole.
For one, I don't even have gcc on servers that I want to deploy to using a virtualenv. but the major pain is finding out what *-dev packages I need to have installed in order to install using pip (if it can be done at all).
I don't think I ever had the IPython qtconsole working from a virtualenv without using system site packages.