monaghans_creed
monaghans_creed

Reputation: 143

Python: installing packages on Mac

I tried to install the pyqt5 package für python 3.9 on Mac. Since it didn't work via pip3 I installed it via Homebrew

% brew install pyqt5

and it seemed to work since the terminal says, if I try

pip3 install pyqt5

the requirements are already satisfied. Yet, if I start PyCharm to to write and test my program it can't find the libraries etc. What do I have to do?

Upvotes: 1

Views: 350

Answers (1)

Baran Karakus
Baran Karakus

Reputation: 303

I just tried to brew install pyqt5 on my Mac. brew then installed a new Python 3.9 interpreter (this is viewed as a dependency of pyqt5).

I suspect the same has happened on your system: brew has installed a whole new Python interpreter, and now when you type pip3 at the command line, you're finding the version of pip installed by brew, which is telling you that pyqt5 has been installed.

However, each Python installation on your system as its own set of packages. Your new Python interpreter has pyqt5 installed, but your original Python interpreter still doesn't.

I suspect that PyCharm is configured to use your default (original) Python interpreter, which doesn't have pyqt5 installed.

Try executing the following at your command prompt (terminal): which pip3. If you're shown a path /usr/local/Cellar/... then this confirms that when you type pip3 at the command line you're actually referring to the version of pip corresponding to a Python interpreter installed by brew.

OK, so what to do going forward?

Two options:

  1. Work with this new Python installation. Then, you'll need to install all of the packages in your previous version of Python again (e.g. just because you had Numpy installed on your original Python installation doesn't mean you'll have it installed by default for your new Python interpreter). Further, you'll have to configure Pycharm to use this Python installation. I don't know the exact steps for this, but go to the Preferences tab and look for something along the lines of 'Python Interpreter' underneath 'Project Settings'.

  2. Remove the new Python installation, figure out what's up with pip, install your desired package.

I'd go with 2). It can get messy to have multiple different versions of Python on your system, unless they're managed by an environment manager such as conda.

To that end, what went wrong when you first tried to install pyqt5?

Upvotes: 1

Related Questions