PyQt5 import Error - python-3.x

I am trying to create a GUI that I can all it from the terminal (Ubuntu here). The problem is, whenever I try to run the code from the terminal, I get the following message:
Traceback (most recent call last):
File "alert.pyw", line 3, in <module>
from PyQt5.QtCore import *
ImportError: No module named 'PyQt5'
The problem is: I only get this message when I try to call the program from the terminal using
python3 alert.pyw Hello
PyQt5 is installed and when I import it from the shell it (apparently) works fine...

Related

pytest does not finde third party lib but python does

I have an script that I want to test:
my script:
from jsonschema.exceptions import ValidationError
import traceback
from data_product.event_processor import DwhUnknownActionError
from data_product.gateway import DwhDataRankingError
...
my test file:
from iterator_processor import IteratorProcessor
calling: pytest will give this error message:
==================================================================================== ERRORS =====================================================================================
__________________________________________________________________ ERROR collecting iterator_processor_test.py __________________________________________________________________
ImportError while importing test module '/home/a05922/dwh-jobs/src/main/lib/python_lib/data_product/iterator_processor_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
iterator_processor_test.py:5: in <module>
from iterator_processor import IteratorProcessor
iterator_processor.py:4: in <module>
from jsonschema.exceptions import ValidationError
E ImportError: No module named 'jsonschema'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
============================================================================ 1 error in 3.19 seconds ==========================================================================
calling python3 iterator_processor.py on the other hand gives me:
Traceback (most recent call last):
File "iterator_processor.py", line 7, in <module>
from data_product.event_processor import DwhUnknownActionError
ModuleNotFoundError: No module named 'data_product'
an error that I 100% expect because the file is in the data_product folder. (the script is meant to be called from outside)
what irritates me is that pytest can not find jsonschema while python3 findes the library without problems.
did anybody have a similar problem?
how do I fix this?
Is this a bug in the pytest library?
should I report this?
how do I report this?
how to I check if anybody has reported this already?

Cannot import installed python package (MacOS)

I cannot import any python package when running python on Visual Studio code or on my Terminal. I can still do this if I were to code on a Jupyter notebook. However, when I tried other environment that doesn't use the notebook server. It returns me ModuleNotFound Error like this
Traceback (most recent call last):
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/test_PreprocessText.py", line 1, in <module>
import PreprocessText
File "/Users/truongminh/Desktop/DataScience/Datasets/CityU Text/PreprocessText.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Most of my packages was download via anaconda. I don't know if it might be the cause of this.

import module error python3 xubuntu 19.04

When importing PyGame using the interpreter it is successful. Using Geany it is not.
shows the error.
I have tried editing the shebang, renaming the file. making sure the PATH and version were correct, and that there were no missing Geany plugins.
import pygame
pygame.init()
Error in Geany:
Traceback (most recent call last):
File "moduleerror.py", line 3, in <module>
import pygame
ImportError: No module named pygame
I went into Build >> Set Build Commands and under Execute commands changed
python "%f"
to
python3 "%f"

ImportError: libQt5WebKitWidgets.so.5: cannot open shared object file: No such file or directory

Hi I am trying to work with pyqt5 on python 3.
When I import QWebPage and QWebView from PyQt5QtWebKitWidgets
I get error
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
Error is:
Traceback (most recent call last):
File "fancybrowser.py", line 49, in <module>
from PyQt5.QtWebKitWidgets import QWebPage, QWebView
ImportError: libQt5WebKitWidgets.so.5: cannot open shared object file: No such file or directory
I am on arch linux and using i3 window manager.
Previously it was working at the time when I was on GNOME.
I dont know but may be it has to do something with it.
Also I followed this link:
https://bbs.archlinux.org/viewtopic.php?pid=1655833#p1655833
but it doesnot help me too.
Plese help me to solve this.

pyuic4 Import error

I'm using PyQt-Py3.3-x64-gbl-4.9.5-1 package on a Windows7 64bit machine. I'm just trying to get start with PyQt so just created a simply window but when I execute the command to create the code I get this error. Any help will be appreciated.
c:\Python33\Lib\site-packages\PyQt4>pyuic4 -o FirstApp.py -x FirstApp.ui
Traceback (most recent call last):
File "C:\Python33\Lib\site-packages\PyQt4\uic\pyuic.py", line 31, in <module> from PyQt4 import QtCore
ImportError: DLL load failed: %1 is not a valid Win32 application.
Usage from the command line is(from my machine):
C:\Python27\Lib\site-packages\PyQt4>pyuic4.bat inputfile.ui > output.py
After the above step add these lines in your output.py file
if __name__=='__main__':
import sys
app=QtGui.QApplication(sys.argv)
Form=QtGui.QWidget()
ui=Ui_Form()
ui.setupUi(Form)
Form.show()
sys.exit(app.exec_())

Resources