I'm trying to learn python practically.
I installed PIP via easy_install and then I wanted to play with some mp3 files so I installed eyed3 via pip while in the project directory. Issue is that it installed the module into python 2.7 which comes standard with mac. I found this out as it keeps telling me that when a script does not run due to missing libraries like libmagic and no matter what I do, it keeps putting any libraries I install into 2.7 thus not being found when running python3. My question is how to I get my system to pretty much ignore the 2.7 install and use the 3.7 install which I have.
I keep thinking I am doing something wrong as heaps of tutorials breeze over it and only one has so far mentioned that you get clashes between the versions. I really want to learn python and would appreciate some help getting past this blockage.
Assuming you're not using virtual environments (and not willing to change to doing so):
The guaranteed safe way to do this is to never run
pip
as a script, only run it as a module. That way, you can explicitly use the Python executable from whichever Python installation you're trying to install things for.For example, if you run the Apple-preinstalled Python 2.7 with
python
and your Python 3.7 install withpython3
, just do this:If you only have one Python 2.x and one Python 3.x, you can almost always get away with using the
2
and3
suffix:If you have multiple 2.x or multiple 3.x, but only one of each
.x
, you can often get away with using thex.y
suffix:One thing that makes things easier for macOS users:
By default, Apple's pre-installed Python requires
sudo
to install packages, while python.org, Homebrew, and many other third-party Python installations do not. So, if you haven't changed anything from the default, and you're careful to never usesudo
withpip
, you can never accidentally install for the Apple pre-installed Python; you'll just get an EPERM error instead of a misleading success.