5 ms·
As an outsider who only uses Python when I need a specific tool that's only available through pip: it's still one of my biggest nightmares. Every single time I
by iagooar 8y ago
As an outsider who only uses Python when I need a specific tool that's only available through pip: it's still one of my biggest nightmares.
Every single time I need to install something with pip on MacOS there is this hour-long struggle with figuring out how to get the correct version of Python (2.7 vs 3) working with the correct version of pip working with the correct version of the library itself.
I don't know, I guess people who use Python regularly have figured it out, or maybe it's just a MacOS thing. For me, it's just a major PITA even 10 years after release.
- mehrdadn 8y agoI don't have a Mac and maybe you've already tried this, but just in case, you can always do python2 -m pip install ... or python3 -m pip install ... to make sure it's running within that particular Python installation. You can use the --user flag to install to your user directory as well, if the system level is annoying.
- singularity2001 8y agowhy is it that the pip command can't handle what it's supposed to do, instead you have to resort to `python3 -m pip install`? Hell, it even breaks itself: pip install --upgrade pip # => pip unusable https://github.com/pypa/pip/issues/5447 https://github.com/pypa/pip/issues/5447 https://github.com/pypa/pip/issues/5221 https://github.com/pypa/pip/issues/5221 etc
- mehrdadn 8y agoWell pip is only one command, so it can't simultaneously work for both Python 2 and Python 3. And if you happen to have another installation of Python or pip in your path (e.g. at the user-level) but not have the other one there, then they'd affect different installations entirely. When you run it via Python you know it's affecting exactly the same installation. Upgrading pip itself is kind of a special case I think. You don't want to upgrade stuff managed by a system package manager using pip; their work will conflict with each other. This includes pip itself. I think this is kind of a mess and I don't know of a great way to deal with it other than just remembering not to upgrading system packages using pip (yes this includes pip itself, and means you should avoid trying to upgrade via --user if it's installed on the system). On Windows where I am it's ironically less annoying since there's no system-level package manager to worry about... go figure.
- prepend 8y agoHow would pip know if you want python3 or 2? On Mac, the system uses python2 so pip and python link to py2. You can change the system -not fun- or wait for apple to upgrade to py3. Ive been waiting a long time. There are tools like conda that do manage py2 and py3 projects living in harmony.
- mixmastamyk 8y agoNope, pip2, pip3. I upgrade all the time no problems, lin and win however.
- raverbashing 8y agoCreate a virtualenv and install the version you need of Pip there Or use Anaconda, which is your own Python "Disneyland" but it is hard to interface with external infrastructure
- guitarbill 8y agowith homebrewed python, i use 'pip2' or 'pip3' and haven't had an issue (or better yet, a virtualenv with the appropriate interpreter). don't use apple's default python. hope that helps!
- Al-Khwarizmi 8y agoI use Ubuntu and it's the exact same thing for me, so I don't think it's MacOS-specific. To be honest, the whole versioning quagmire is the main reason why I don't use Python as one of my main languages, but just as an outsider like you. I like the language but I hate wasting my time with that kind of thing. Say what you will about Java, but you can just slap a jar file into a folder and it will work with the latest version, with zero drama.
- mehrdadn 8y agoI feel like the fundamental issue is that it simply does not make sense for pip to be able to install or upgrade any Python packages managed by the system package manager, any more than it makes sense for it to upgrade the system-level Python interpreter itself. It should just outright not have the ability to do this.
- c22 8y agoOn my Debian box I notice I have pip2.7 and python2.7, but also pip3.4, python3.4, pip3.6, python3.6, etc... If I want to install something for python2.7 I just use pip2.7. It looks like on this system python and pip are just symlinks to python2.7 and pip2.7 while python3 and pip3 link to python3.8 and pip3.8 It never seemed that hard to keep track of the different versions.
- yodsanklai 8y agoNever had any issue with python on mac os. I install python with homebrew and then use pip3 and python3.
- tarboreus 8y agoi highly recommend pyenv to resolve this issue on Mac OS and Linux: https://github.com/pyenv/pyenv https://github.com/pyenv/pyenv
- brennebeck 8y agoSeconded. Pyenv has made life much better for me when using system-wide py utils.
- t0mbstone 8y agoYep! Pyenv for Python, rbenv for Ruby, NVM for node.
- h1d 8y agoMy experience using nvm has been quite annoying. What you could do with simple npm command now doesn't work unless you give additional command lines when it comes to cron and other non interactive environments like process monitoring to restart the process.
- flashgordon 8y agoOut of curiosity do you use virtual environments? I had this same problem until I became very liberal with my use of virtual environments.
- c8g 8y agoI always use "python -m pip install TOOL_NAME" or "python3 -m pip install TOOL_NAME".
- girzel 8y agoFor anything larger than a medium-sized single-file script, I use pipenv. It's basically a tie-in between pip and virtualenv, and in my opinion is ideal for creating isolated environments quickly, intuitively, and reproducibly. I haven't had Python frustrations since starting to use pipenv. I was not paid for this message :)
- mixmastamyk 8y ago$ pip3 install foo Or pip3.6 etc --user is useful also