How do i get Mac 10.13 to install modules into a 3.x install instead of 2.7

79 Views Asked by At

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.

2

There are 2 best solutions below

0
On BEST ANSWER

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 with python3, just do this:

python3 -m pip install eyed3

If you only have one Python 2.x and one Python 3.x, you can almost always get away with using the 2 and 3 suffix:

pip3 install eyed3

If you have multiple 2.x or multiple 3.x, but only one of each .x, you can often get away with using the x.y suffix:

pip3.7 install eyed3

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 use sudo with pip, you can never accidentally install for the Apple pre-installed Python; you'll just get an EPERM error instead of a misleading success.

0
On

Have you tried pip3 install [module-name]?

Then you should be able to check which modules you've installed using pip3 freeze.