PyQt5 not recognized (Solved)


I have recently installed Atom to code PyQt5 applications. I am still learning how to configure Atom. I have installed “script” to run python scripts but my first test has had negative results. The PyQt window is coded correctly but atom does not recognize PyQt5
running the script gave the following message.

File “/home/liamdale/Python/Projects/Lasole/”, line 8, in <module>
from PyQt5.QtCore import *
ImportError: No module named PyQt5.QtCore

The package verification did not give me any indication of the proble

Ubuntu 18.04: Package 'scritp' doesn't run Python modules (like numpy and pandas)

pip3 install PyQt5


Sorry I didn’t express myself correctly. PyQt5 is installed and I’ve been using it. The Script I used to test Atom was a tested working. There is no reason that I can Identify why Atom doesn’t display the window. I even wrote a basic PyQt5 script to display an empty window and still get the same message. The simple window was executed from the terminal prompt. It worked.


Further testing
I found an icon on the bottom right which transfers the script output to another window.
I used it and got the terminal command used by “Atom”. The output was:

[Command: /usr/bin/python3 -u /home/liamdale/Python/Research/Atom/]
Traceback (most recent call last):
File “/home/liamdale/Python/Research/Atom/”, line 15, in
from PyQt5.QtWidgets import QApplication, QWidget
ModuleNotFoundError: No module named ‘PyQt5’
[Finished in 0.031s]

I tested the script command on my OS terminal and got:

qt5ct: using qt5ct plugin

and the QT window appeared on the screen.

so the command that the Script plugin uses works but “Atom” does not recognize that fact for some reason.


Atom doesn’t recognize anything because Atom has no concept of Python code. script doesn’t recognize anything because all script does is ship the code over to the Python interpreter.

Is there a chance that you have PyQt5 installed under Python 2?


I realize that script executes the python script (Not Atom directly).

I checked PyQt5 is installed for python3, I don’t use python2 at all.

PyQt5 is installed in /usr/lib/python3/dist-packages

I’ve reviewed script’s settings but can’t find anything which will help

I don’t know if the fact I’m using mint cinnamon 19.1 is important because script seems to use my OS’ terminal to execute the code.


Try printing sys.path from a script inside Atom.


Some useful tips were read here.

It seems that py2 is default in script package.

Can you not write a python3 shebang at top of py script to force py3 usage?

[Later edit]

Following video in above link I navigated to …

Atom > Edit > Preferences > open Config Folder > Packages > Script > Lib > Grammars > … to read here …

exports.Python = 'Selection Based': command: 'python' args: (context) -&gt; ['-u', '-c', context.getCode()]

'File Based': command: 'python' args: ({filepath}) -&gt; ['-u', filepath]

Conclusion: If running command python in terminal launches default py2 then the python variable in above needs to be changed to python3.

[And another thought]

If editing bear in mind this advice …


Mar '18

Keep in mind that when you edit a file inside .atom/packages/ , that edit will be erased the next time the package gets updated.


My initial test of Atom with PyQt5 script used a shebang header.
I then tried it without a shebang. The difference was in the output of the command
In the first case the python3 (with its path) was used. In the second case only
the command python (without a path) was used.
I tested the commands exactly as written in the Atom output on my system terminal.
In the first case (with shebang) the script executed correctly and the Qt Window was displayed.
In the second case (without shebang) the script displayed the same error as indicated in Atom output

~$ python -u /home/liamdale/Python/Research/Atom/
Traceback (most recent call last):
File “/home/liamdale/Python/Research/Atom/”, line 15, in
from PyQt5.QtWidgets import QApplication, QWidget
ImportError: No module named PyQt5.QtWidgets

You are right the default is python 2. The configuration changes proposed did change
the default to python3 but the problem persists. For some reason Atom-Script can’t find
the PyQt5 modules

With the configuration changes the atom-script command executes correctly with or without a shebang
on my cinnamon terminal but not in Atom. Odd!!

I will keep hunting for an answer.


Try printing sys.path from a script inside Atom using the python3 command.


The result of print(sys.path)

[Command: python3 -u /home/liamdale/Python/Research/Atom/]
[’/home/liamdale/Python/Research/Atom’, ‘/usr/lib/’, ‘/usr/lib/python3.7’, ‘/usr/lib/python3.7/lib-dynload’, ‘/usr/lib/python3.7/site-packages’, ‘/app/lib/python3.7/site-packages’]

Traceback (most recent call last):
File “/home/liamdale/Python/Research/Atom/”, line 16, in
from PyQt5.QtWidgets import QApplication, QWidget
ModuleNotFoundError: No module named ‘PyQt5’
[Finished in 0.031s]

The first path /home/lia… is the working directory where the script is stored.

I notice that the PyQt5 is located in /usr/lib/python3/dist-packages
could the problem be the difference in /usr/lib/python3.7 and /usr/lib/python3


After the previous post I executed the same script in Eric-IDE and found that the sys.path is different:

/home/liamdale/Python/Research/Atom’, ‘/usr/share/eric/modules/DebugClients/Python’, ‘/usr/lib/’, ‘/usr/lib/python3.6’, ‘/usr/lib/python3.6/lib-dynload’, ‘/usr/local/lib/python3.6/dist-packages’, ‘/usr/lib/python3/dist-packages’, ‘/usr/lib/python3.6/dist-packages’

Clearly the paths point to a different area. My system uses python 3.6,7. I also notice that /usr/lib/python3/dist-packages is in the Eric-IDE path identification.

I’ve checked my usr folder for python3.7 folder. It exists but rudimentary with only three folders Distutil, lib2to3 and lib-dynload. and no other files

How to change Atom configuration to point to right paths?


To complete the picture, you should try executing that sys.path script from the terminal using python3, then you can check the environment variables and compare them to what you see from inside Atom using a package like termination.

If you don’t use 3.7 at all, you can uninstall it. If you want to keep both, then seeing the PATH variable will tell you how to change your system’s configuration so that Python 3.6 comes first when it goes looking for python3. And you compare it against Atom’s environment to make sure nothing weird is going on.

When doing testing like this, what other IDEs do isn’t very helpful because you’re introducing extra unknowns (I know nothing about Eric-IDE). You should try first to compare the behavior inside Atom to the behavior of the naked Python interpreter from the terminal.


I hesitate to suggest this since it might send you off on a wild goose chase. I am a sucker for experimenting and sometimes it does not always work out.

However I am researching installation of Python and R and I can remember using miniconda (not the full blown anaconda installation) to create separate environments for python.

This blog explains …

If not today, perhaps park this idea (miniconda) to try with Atom at some stage.


Your right the best way to check the python paths is using the interpreter itself.

The results:

$ python3
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.

import sys
[’’, ‘/usr/lib/’, ‘/usr/lib/python3.6’, ‘/usr/lib/python3.6/lib-dynload’, ‘/usr/local/lib/python3.6/dist-packages’, ‘/usr/lib/python3/dist-packages’, ‘/usr/lib/python3.6/dist-packages’]

It is appearent that the python 3.6.7 is the installed python3.

I don’t know how the folder 3.7 was installed or why Atom uses the 3.7 paths.
I used flatpak to install Atom. There may be a relationship.

I hesitate to uninstall the python3.7 using the Apt utility, not knowing how it was installed.
Synaptic package manager showed that python3.7 is not installed while 3.6 is installed.

The Atom-Script code in the lib folder I found:

‘File Based’:
command: ‘python3’
args: ({filepath}) -> [’-u’, filepath]

The file path is defined. Where in the code is the application path defined? This would seem to be the place to change the paths.

I have noted the last reply concerning miniconda. I will check it out.


That’s something you should mention in the first post. It’s not an officially supported method of installation and it’s possible that it’s contributing to your problem.

What do you see in the environment variables inside Atom compared to those outside it? If they’re different (which I expect given what I now know), then Flatpak is creating a virtual environment.

The file path is defined. Where in the code is the application path defined? This would seem to be the place to change the paths.

The “application path” is python3. That’s what script is asking for, and the problem is not inside Atom.


Indeed so. Apparently Flatpak creates a sandbox and OP is trying to use Atom to access the innards of sandbox.

After further reading I see that Atom can be installed from FlatHub. So I wonder if one way forward is for OP to integrate Atom into FlatPack stack at least for development.


This was my first experience with flatpak. I read the reference provided. The use of flatpak does not seem to a straight forward installation program. If I understand correctly, flatpak can be an environment and continues to be present after the installation is completed. So my version is operating inside flatpak and it’s flatpak that is supplying the path to python 3.7.

Correct me if I’m wrong but the probable solution to my problem is the removal of Atom using flatpak and the re-installation in the usual way either with the Apt utility or with a .deb file.

I checked Synaptic, it does not seem to be in its library.


As explained a Flatpack app is isolated in a virtual sandbox in Ubuntu. Flatpack has installed python 3.7 into the sandbox, while Ubuntu desktop is in a different universe.

You could remain with Flatpack and install Atom from Flathub. But then you would have two Atom editors to contend with.

Or you could unwind from Flatpack and get PyQt5 working in your Ubuntu desktop with an earlier version (3.6) of python. That is what I would do.

You could also upgrade your Ubuntu desktop python to 3.7 to fall into line with Flatpack.

[Further explanation]
You wrote …

Correct me if I’m wrong but the probable solution to my problem is the removal of Atom using flatpak and the re-installation in the usual way either with the Apt utility or with a .deb file.

Are you using Atom inside your Flatpack app or Atom in your Ubuntu desktop which is served by Synaptic Package Manager?


Problem solved !
I used flatpak to uninstall Atom.
Downloaded the.deb file at Atom website and installed it
Test the same simple window apt and it worked.
Since the Script had a python3 shebang, I removed it and got an error message
Atom is configured out of the box for python 2
I went to the (thanks to d_l for showing me how!) and change the commands from python to python3, saved, restarted Atom and test the simple window script with a shebang.

The sys.path out is:

[Command: python3 -u /home/liamdale/Python/Research/Atom/]
[’/home/liamdale/Python/Research/Atom’, ‘/usr/lib/’, ‘/usr/lib/python3.6’, ‘/usr/lib/python3.6/lib-dynload’, ‘/usr/local/lib/python3.6/dist-packages’, ‘/usr/lib/python3/dist-packages’, ‘/usr/lib/python3.6/dist-packages’]
qt5ct: using qt5ct plugin
[Finished in 5.558s]

Thanks to all for your help.
One last question. Since this is my first post is it customary to tag my first post as “Solved”