Difficulty installing/importing pyqt5 on ubuntu 18.04 - python

Goal: To import pyqt5 into python3 under Ubuntu 18.04
I know there are many answers to similar questions here and elsewhere. I have tried a lot of them, but I don't see anything that exactly matches my situation.
Starting with a clean installation of Ubuntu 18.04, I have tried many ways to be able to have the statement import pyqt5 succeed in Python 3.6.9, which is the default python3 on this distribution.
None of them have succeeded.
In several attempts, reinstalling Ubuntu anew several times, I have had pip3 either experience a 404 downloading https://pypi.org/simple/python3-pyqt5/ and confirmed the error by pasting the URL into Firefox and also getting a 404. (I also checked the Firefox was working fine accessing the Internet)
But usually I run through a process that seems to indicate that pyqt was loaded successfully but was still unable to import it in Python3.
Among the things I've tried from various web sites are:
pip3 install --upgrade pip
pip3 install pyqt5==5.14.0 vs pip3 install pyqt5 (defaulting to 5.14.1)
installing a simple pypi module and finding that I can import it into Python3 with no problem
running pip3 under sudo
upgrading python3 to Python 3.7.4
A more complete list of what I did starting with the reinstall is shown below.
Any suggestions for solutions or what to look at on my system?
I have a bootable memory stick of Ubuntu 18.04.4 that I created last week by downloading the executable from Ubuntu.com. Everything that's packaged with the release seems to work fine, including Python 3.6.9 in other situations. I do virtually nothing except the following steps.
sudo apt install python3-pip
pip3 install humanfriendly (just to ensure that pip3 works for a simply pypi module)
pip3 install --upgrade pip
pip3 install python3-pyqt5
sudo apt-get install pyqt5-dev-tools (no complaints from pip3 seems to work okay)
sudo apt-get install qttools5-dev-tools (seems to work)
in python3
>>>import pyqt5
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyqt5'
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.0)
pip3 install pyqt5 --user (Successfully installed pyqt5-5.14.1
Try to import in python3 again, same result: "No module named 'pyqt5'"
cd ~/.local/bin
ls
humanfriendly pip pip3 pip3.6 pylupdate5 pyrcc5 pyuic5
(there seems not to be an entry for pyqt5 although there is for some of its stand-alone componentes)
pip3 uninstall pyqt5
ls
humanfriendly pip pip3 pip3.6
(what was there went away)
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.1)
pip3 install pyqt5 --user (seems to succeed)
try to import in python3 (same error)
pip3 uninstall pyqt5 (Successfully uninstalled PyQt5-5.14.1)
next I tried sudo pip3 uninstall pyqt5
seems to work; not importable in python3; sudo pip3 uninstall
next I created a virtual env, ~/.vents/tevs
activate the venv
pip3 install pyqt5==5.14.0
Installing collected packages: PyQt5-sip, pyqt5
attempt to import pyqt5 in python3: fails as before
pip3 uninstall pyqt5
(Successfully uninstalled PyQt5-5.14.0 after listing thousands of files
in .venvs/tevs/lib/python3.6/site-packages/PyQt5)
pip3 install python3-pyqt5
(fails with HTTP Error: 404 Client Error:
Not Found for url: https://pypi.org/simple/python3-pyqt5/)

Several problems should be noted in what the OP notes:
The name of the library does not necessarily match the name of how to import the libraries, on the other hand pip accepts names like pyqt5 and PyQt5 as equivalent, but when you import it you should use PyQt5, not pyqt5, so to test that you have installed you can do the following:
Run on the console:
$ python3 -c "from PyQt5.Qt import PYQT_VERSION_STR; print(PYQT_VERSION_STR)"
5.14.1
Run on python console:
Python 3.8.1 (default, Jan 22 2020, 06:38:00)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from PyQt5.Qt import PYQT_VERSION_STR
>>> print(PYQT_VERSION_STR)
5.14.1
python3-pyqt5 is the name of the package that offers ubuntu repositories for the version of pyqt5 that your community compiles which is generally a non-current version. So to install pyqt5 there are several methods:
Using ubuntu repository: sudo apt-get install python3-pyqt5
Using pip: python3 -m pip pyqt5 (You must use sudo if required) or python3 -m pip install pyqt5 --user (This method also applies to virtualenv)
So I can conclude that the OP has successfully installed PyQt5 but has failed to verify if the installation has been correct so I recommend using what is indicated in (1)

I recently encountered this problem on Ubuntu 20.04 and here is what worked for me.
Firstly, after trying much of what you described I finally decided to run python --version from terminal and the output told me that python 2.7 was the default version on my system. This was the problem.
Secondly, after thinking "sheeeee-*t partner", I checked for any python2 dependencies using apt rdepends python --installed.
Lastly, after confirming that I had no python2 dependencies, I ran sudo apt-get install python-is-python3 in order to make python3 the default version.

Related

No matching distribution found for PyQt5

I install a rasbian os on my vmware workstation and I am currently trying to install some packages and modules. I have a problem with pip. I try:
sudo pip install PyQt5
sudo pip3 install pyqt5
sudo python3 -m pip install PyQt5
I got the same error.
ERROR: Could not find a version that satisfies the requirement pyqt5 (from versions: none)
ERROR: No matching distribution found for pyqt5
I try to install PyQt5 manually and for that I install sip with sudo pip3 install sip after that I try to configure pyqt5 files with python configure.py but I got this error:
Error: Unable to import PyQt5.sip. Make sure you have configured SIP to create a private copy of the sip module.
I already install sip. But my main problem is about pip. It's not working like I expect
I'm not sure if it's about pip or it is a problem about operating system (or if it is about me).
python --version:2.7.16
python3 --version:3.7.3
pip --version I got the error
Traceback (most recent call last):
File "/usr/local/bin/pip", line 6, in <module>
from pip._internal.main import main
ImportError: No module named main
sudo pip --version :19.3.1
pip3 --version :18.1
lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 10 (buster)
Release: 10
Codename: buster
I had some error, when tried to install on virtualenv. It helped me:
pip install --upgrade pip
Before I had 19.0.3 versin and upgraded to 22.0.4
then:
pip install PyQt5

Python on anaconda cannot find azure.mgmt.datafactory

I am trying to run this tutorial
https://learn.microsoft.com/en-US/azure/data-factory/quickstart-create-data-factory-python
but I fail to install the packages. I tried several installations but I keep getting the error No module named 'azure.mgmt.datafactory' when trying to run from azure.mgmt.datafactory import DataFactoryManagementClient.
I am using anaconda and windows 10.
I tried running the recommended anaconda packages https://anaconda.org/anaconda/azure and https://anaconda.org/clinicalgraphics/azure-mgmt-resource under a python 3.5 environment and I also tried to manually install everything from github (https://github.com/Azure/azure-sdk-for-python) using
git clone git://github.com/Azure/azure-sdk-for-python.git
cd azure-sdk-for-python
python setup.py install
In both the normal (Python 3.6) and the new (Python 3.5, using Anaconda version with Python 3.5) environment. None of this worked.
What am I missing?
(Note that from azure.mgmt.resource import ResourceManagementClient worked fine with the anaconda installation)
EDIT
After the first response, I ran the following commands from the powershell
pip install azure-mgmt-resource
pip install azure-mgmt-datafactory
pip install azure-mgmt
which resulted in ModuleNotFoundError: No module named 'azure.mgmt'
Uninstalling the three packages and installing azure-mgmt as a first one did not solve the issue either. However, I don't know how to uninstall the manually installed package from python setup.py install, which still might be an issue.
Have you tried pip install in powershell/cmd?
pip install azure-mgmt-datafactory
Update (Jan's answer):
pip freeze > requirements.txt
pip uninstall -r requirements.txt
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory (this might not be needed as it comes with azure-mgmt)
Ok, this is how I got the required azure libraries to work (thx to Saul Cruy, who gave me the idea)
Using this post What is the easiest way to remove all packages installed by pip?, I created a requirements file in PowerShell
pip freeze > requirements.txt
In this file, I manually kept only the entries with azure.
Then, I deleted all packages in the file
pip uninstall -r requirements.txt
The steps above were repeated twice, as upon first delete, some azure packages survived.
Then, I ran (all in PowerShell, in that order)
python -m pip install azure-common
python -m pip install azure-mgmt
python -m pip install azure-mgmt-datafactory
The reason might(!) be that installing packages in the anaconda console using the conda commands causes confusion in the dependencies (I tried a similar approach in a conda environment as it seemed like a good idea to seperate the azure packages from the other ones, but without success).

How can I pip freeze and get only pip --user installs, no system installs?

I have dutifully uninstalled all the Python packages I installed with sudo pip install and installed them with pip --user install instead. Yay me :)
On Ubuntu, I know I can find the relevant binaries at /home/<USERNAME>/.local/bin and the packages themselves at /home/<USERNAME>/.local/lib/python2.7/site-packages ... but navigating there is not as simple as good old pip freeze.
How can I pip freeze and get only the packages I installed with pip --user install rather than all the Python packages, including those installed via apt?
Currently pip does not have any such options. So with default pip its not possible. (and I submitted a feature request and now there is a working PR too!)
However I wrote a little script, which does solve your problem:
# pip_user_installs.py
import sys
import pkg_resources
for module in pkg_resources.working_set:
if sys.argv[1] in module.location:
print module.project_name
usage:
$ python pip_user_installs.py $HOME
It's fairly easy in recent versions of pip (the PR in the other answer is now part of pip).
pip freeze --user
This will output a list of packages currently installed to the user's site-packages.

ImportError: No module named scipy

I am using Python 2.7 and trying to get PyBrain to work.
But I get this error even though scipy is installed -
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-
py2.7.egg/pybrain/__init__.py", line 1, in <module>
from pybrain.structure.__init__ import *
File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/__init__.py", line 1, in <module>
from pybrain.structure.connections.__init__ import *
File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/connections/__init__.py", line 1, in <module>
from pybrain.structure.connections.full import FullConnection
File "/usr/local/lib/python2.7/site-packages/PyBrain-0.3.1-py2.7.egg/pybrain/structure/connections/full.py", line 3, in <module>
from scipy import reshape, dot, outer
ImportError: No module named scipy
I have installed scipy using this command -
sudo apt-get install python-scipy
I get -
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-scipy is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
What should I do?
Try to install it as a python package using pip. You said you already tried:
sudo apt-get install python-scipy
Now run:
pip install scipy
I ran both and it worked on my Debian-based box.
To ensure easy and correct installation for python use pip from the get go
To install pip:
$ wget https://bootstrap.pypa.io/get-pip.py
$ sudo python2 get-pip.py # for python 2.7
$ sudo python3 get-pip.py # for python 3.x
To install scipy using pip:
$ pip2 install scipy # for python 2.7
$ pip3 install scipy # for python 3.x
For windows users:
I found this solution after days. Firstly which python version you want to install?
If you want for Python 2.7 version:
STEP 1:
scipy‑0.19.0‑cp27‑cp27m‑win32.whl
scipy‑0.19.0‑cp27‑cp27m‑win_amd64.whl
numpy‑1.11.3+mkl‑cp27‑cp27m‑win32.whl
numpy‑1.11.3+mkl‑cp27‑cp27m‑win_amd64.whl
If you want for Python 3.4 version:
scipy‑0.19.0‑cp34‑cp34m‑win32.whl
scipy‑0.19.0‑cp34‑cp34m‑win_amd64.whl
numpy‑1.11.3+mkl‑cp34‑cp34m‑win32.whl
numpy‑1.11.3+mkl‑cp34‑cp34m‑win_amd64.whl
If you want for Python 3.5 version:
scipy‑0.19.0‑cp35‑cp35m‑win32.whl
scipy‑0.19.0‑cp35‑cp35m‑win_amd64.whl
numpy‑1.11.3+mkl‑cp35‑cp35m‑win32.whl
numpy‑1.11.3+mkl‑cp35‑cp35m‑win_amd64.whl
If you want for Python 3.6 version:
scipy‑0.19.0‑cp36‑cp36m‑win32.whl
scipy‑0.19.0‑cp36‑cp36m‑win_amd64.whl
numpy‑1.11.3+mkl‑cp36‑cp36m‑win32.whl
numpy‑1.11.3+mkl‑cp36‑cp36m‑win_amd64.whl
Link: [click[1]
Once finish installation, go to your directory.
For example my directory:
cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip install [where/is/your/downloaded/scipy_whl.]
STEP 2:
Numpy+MKL
From same web site based on python version again:
After that use same thing again in Script folder
cd C:\Users\asus\AppData\Local\Programs\Python\Python35\Scripts>
pip3 install [where/is/your/downloaded/numpy_whl.]
And test it in python folder.
Python35>python
Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:18:55) [MSC v.1900 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.
>>>import scipy
I had a same problem because I installed both of python2.7 and python3. when I run program with python3 I received same error.
I install scipy with this command and problem has been solved:
sudo apt-get install python3-scipy
if you are using pycharm go to settings and in project interpreter sub-tab click on "+" sign next to list and in the search bar in there search name "scipy" and install the package.
If you need to get scipy in your Python environment on Windows you can get the *.whl files here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy
Remember that you need to install numpy+mkl before you can install scipy.
https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy
When you have downloaded the correct *.whl files just open a command prompt in the download directory and run pip install *.whl.
For Windows User :
pip install -U scipy
I recommend you to remove scipy via
apt-get purge scipy
and then to install it by
pip install scipy
If you do both then you might confuse you deb package manager due to possibly differing versions.
Try to install it as a python package using pip as follows
$ sudo apt-get install python-scipy
If you want to run a python 3.x script, install scipy by:
$ pip3 install scipy
Otherwise install it by:
$ pip install scipy
This may be too basic (and perhaps assumable), but -
Fedora users can use:
sudo dnf install python-scipy
and then (For python3.x):
pip3 install scipy
or (For python2.7):
pip2 install scipy
Your python don't know where you installed scipy. add the scipy path to PYTHONPATH and I hope it will solve your problem.
My problem was that I spelt one of the libraries wrongly when installing with pip3, which ended up all the other downloaded libaries in the same command not being installed. Just run pip3 install on them again and they should be installed from their cache.
Use sudo pip install scipy to install the library so It cannot ask for permissions later
in previous steps by #user5747799, it do not work directly but instead change the URL (https://bootstrap.pypa.io/pip/2.7/get-pip.py) and now spicy work very well on Ubuntu 20.04
Also o follow steps to switch between version from https://www.fosslinux.com/39384/switching-between-python-2-and-3-versions-on-ubuntu-20-04.htm
To install pip using alternative URL:
$ wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
$ sudo python2 get-pip.py.2 # for python 2.7 (or verify the result of previous step)
$ sudo python3 get-pip.py # for python 3.x
To install scipy using pip:
$ pip2 install scipy # for python 2.7
$ pip3 install scipy # for python 3.x
in order to verify
$ python
then
>>> import scipy
with no errors to show.
for Mac run below command to install scipy
$ brew install scipy
$ pip install scipy
Try forcing a reinstall of scipy:
python3 -m pip install scipy --force-reinstall
for python3 below command to install scipy
python3 -m pip install scipy

Trying to install OpenCV with Matplotlab

I am attempting to install OpenCV on my linux computerI followed this installation guide:
Linux / Mac Users:
pip3 install numpy or apt-get install python3-numpy. You may need to apt-get install python3-pip.
pip3 install matplotlib or apt-get install python3-matplotlib.
apt-get install python-OpenCV.
...
everything installs, except the last one Python-OpenCV
error:
E: unable to locate package python-OpenCV
and then when I run python in the terminal and try to run:
import matplotlab
I get the error
Traceback (most recent call last):
file "stdin>", line 1, in <module>
Importerror: no module named 'matlabplot'
meanwhile
import cv2
&
import numpy
run without error and seem to work, this is also the case when I run a .py file that calls for importing those three.
Any information will be helpful, i am fairly new to python and linux :)
Use Anaconda, there are download for Windows, Linux and Mac. Installation is easy.
I would suggest you download Anaconda2.
Then install with command (on Linux) (more documentation on installation)
bash ~/Downloads/Anaconda2-4.4.0-Linux-x86_64.sh
There are cv2, mathplotlib pre-install
*NOTE: I trying to find mathplotlab or matlabplot with Python on Google but can't find any. Instead, Google suggests mathplotlib. Perhaps you mistake library name
The openCV 3 package is called opencv-python in pip3 (python3). For python2, replace pip3 with pip and python3-opencv with python-opencv
Mac OS (OS X) / Linux
$ pip3 install -U opencv-python
or as mentioned by #GregHNZ on linux
$ apt-get install python3-opencv
All versions are imported with import cv2 inside python scripts.
Probably you can import cv2and numpybecause it is installed for dependency reasons by other packages.
As in comments already mentioned probably you mean matplotlib

Categories

Resources