ImportError: No module named 'PyQT5' Ubuntu 16.10 - python-3.x

I wanted to do some Python3 Development.
I did:
$ sudo apt-get install python3-pyqt5
But it doesn't work:
python3
$ python3
Python 3.5.2+ (default, Sep 22 2016, 12:18:14)
[GCC 6.2.0 20160927] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQT5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'PyQT5'
>>>

You need to pip install it :
pip3 install PyQt5

Even though one often reads "QT", the package name is not "PyQT5" but rather "PyQt5" with a lowercase 't' at the end.

Related

python does not import module after pip install

can anyone help me figure this one out ??
pip installs the module but python does not find the module after pip install
user#debian:~$ pip install google
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: google in ./.local/lib/python3.10/site-packages (3.0.0)
user#debian:~$ python3.10 -m site
sys.path = [
'/home/user',
'/usr/local/lib/python310.zip',
'/usr/local/lib/python3.10',
'/usr/local/lib/python3.10/lib-dynload',
'/home/user/.local/lib/python3.10/site-packages',
'/usr/local/lib/python3.10/site-packages',
]
USER_BASE: '/home/user/.local' (exists)
USER_SITE: '/home/user/.local/lib/python3.10/site-packages' (exists)
ENABLE_USER_SITE: True
user#debian:~$ python3.10
Python 3.10.0 (default, Sep 11 2022, 13:22:26) [GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import google
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'google'
>>>

Pyserial won't import

Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'serial'
I have tried uninstalling and the reinstalling using:
sudo pip3 uninstall pyserial
sudo pip3 install pyserial
sudo pip3.7 install pyserial
No joy!
Im on a Mac if it matters.
A workaround would be appreciated.

ModuleNotFoundError: No module named 'pandas.compat.numpy' Venv Py3.6.4, pandas 0.220

I'm stuck with a python virtual env installation and particularly pandas.
Pip list:
numpy (1.14.2)
pandas (0.22.0)
pip (9.0.1)
Python 3.6.4 (default, Mar 12 2018, 17:59:42)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pandas
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/me/tensorflow/lib/python3.6/site-packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
ModuleNotFoundError: No module named 'pandas.compat.numpy'
>>>
You probably have several installations of pandas (using apt and using pip)
Remove all:
sudo apt-get purge python3-pandas
sudo pip3 uninstall pandas
Install using pip3:
sudo pip3 install pandas
Try the following and it should work
python3
>>import pandas

python3 tkinter ubuntu trusty does not work under virtual environment

I installed python3-tk on an ubuntu trusty docker container.(apt-get install python3-tk)
> python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> import tkinter as tk
>>>
So far so good. However, for different reasons, I need to run a loaded python3 virtualenv in same container.
When I activate the virtual environment:
(env_py34)root#8a7953c24d4f:/home# python
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 39, in <module>
import _tkinter
ImportError: No module named '_tkinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.4/tkinter/__init__.py", line 41, in <module>
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
>>>
Versions of python are identical.
How come the virtual environment did not inherit python3-tk from the python3 installation? How can I install python3-tk inside the virtual environment?
So from the error message, python3-tk package is missed.
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
Did you try to install it? for example, in ubuntu
sudo apt-get install python3-tk
I had the same problem. The answer provided by user BMW did not work for me. There is no need to recreate the virtualenv directory, like user1256124 suggests, although that is a perfectly workable solution as well.
Just use the bindings specific to the version of python that you need. For python3.6, this command is:
sudo apt-get install python3.6-tk
This allows an already set up virtualenv to find the right libraries.
I figured it out.
What was happening is that once python3 virtualenv was created there was no more inheriting to be done from the python3 apt-get installation.
Once I recreated the image from the updated Dockerfile in which it was specified to apt-get install python3-tk BEFORE creating the python3 virtualenv, then everything worked.
Not sure why this is the case though.

Installing matplotlib for python3 on Ubuntu

I'm running Ubuntu 12.04, and I need to use matpltlib in Python 3.2.3. I successfully installed it using
sudo apt-get install python-matplotlib
But now it works only in Python 2.7, which seems to be the default version:
$ python2
Python 2.7.3 (default, Feb 27 2014, 20:00:17)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>
But python 3 doesn't work:
$ python3
Python 3.2.3 (default, Feb 27 2014, 21:33:50)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named matplotlib
>>>
Also, my python command seems to be 'broken':
$ python
bash: /usr/bin/python: No such file or directory
Any help is appreciated!
In case anyone else stumbles upon this, just use
sudo apt-get install python3-matplotlib
There are many packages involved with matplotlib and using apt-get instead of pip this is the officially recommended approach.
if you are in virtualenv
example: workon cv #cv is my virtualenv name
$ workon cv
$ pip install matplotlib

Resources