3 ms·
One thing I'd like to add/contradict. For system-wide Python packages, avoid pip, use your system package manager, else you will eventually end up with conflict
by antihero 14y ago
One thing I'd like to add/contradict. For system-wide Python packages, avoid pip, use your system package manager, else you will eventually end up with conflicts when something you install requires the library you have pip installed, and your package manager wants to install it. Install virtualenv and virtualenvwrapper with your system package manager! Then use virtualenv for any actual projects you are working on. If your repository version of virtualenv/virtualenvwrapper is outdated, use better repos/PPAs/AUR.
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.
- chimeracoder 14y agoMy workflow (which has never led to conflicts): - 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.?
- mvermaat 14y agoI have a "pip install ipython" in ~/.virtualenvs/postmkvirtualenv to make that a bit easier. 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.
- antihero 14y agoIf you install ipython within your virtualenv it seems to work.
- chimeracoder 14y agoWell yes, but as I said, that's exactly what I don't want to do, because then it'll be included in my requirements.txt file when I run pip freeze (unless I manually delete it each time).
- deleted 14y ago[deleted]