josef.van.niekerk
josef.van.niekerk

Reputation: 12121

Running External Tools from IntelliJ not finding Python libraries

I've setup a few External Tools in IntelliJ (PyCharm) to run pyuic4 and pyrcc4 which are command line utilities used with PyQt to compile QRC resource files and Qt Designer .ui files into Python .py source files.

I've also created a Makefile to run the above tools in one go. When I run either from the terminal, everything works 100%.

I'm finding issues when trying to run these from within IntelliJ, its complaining that it can't find the module named PyQt4, here's the output:

/usr/bin/make all
/usr/local/bin/pyuic4 resources/ui/mainwindow.ui -o output/ui_mainwindow.py
Traceback (most recent call last):
  File "/usr/local/Cellar/pyqt/4.9.4/lib/python2.7/site-packages/PyQt4/uic/pyuic.py", line 31, in <module>
    from PyQt4 import QtCore
ImportError: No module named PyQt4
make: *** [output/ui_mainwindow.py] Error 1

Process finished with exit code 2

I'm assuming this is to do because the External Tools aren't using the same environment variables as when run from the terminal?

Does anyone have a suggestion on how to rectify this in IntelliJ?

Upvotes: 0

Views: 1980

Answers (1)

CrazyCoder
CrazyCoder

Reputation: 402065

Check this answer for the instructions how to make GUI apps environment the same as in Terminal.

Another option is to start PyCharm from the Terminal so that it inherits the environment:

open -a /Applications/PyCharm.app/

Upvotes: 1

Related Questions