PyQt5: ImportError: No module named sip - python

This has me completely bamboozled. I wanted to compile PyQt5. To do that I first need to compile and install sip. So I compiled and installed sip. Then I compiled and installed PyQt5. No problems so far. Then I tried it out.
$ python
Python 2.7.13 (default, Sep 26 2018, 18:42:22)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sip
>>> import PyQt5
>>> from PyQt5 import QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named sip
>>>
What??? I had to have sip installed to compile PyQt5. I had to have sip installed to import it. Why is it now telling me that there is "No module named sip?"

I had this problem with system packages (installed via apt), with a virtual env created with --system-site-packages, and I don't have it inside a proper virtual env. Python3.6, LinuxMint 19.

I had this problem when I was inside (venv) running the python from the venv/bin
it cleared and found sip when I used usr/bin/python
(in my setup they were the same versions, please check you product and setup that the virtual py is not needed)

Related

"All requested packages already installed" but "ModuleNotFoundError"

I'm running python 3.9 and my goal is to install and import pyscopg2:
python --version
Python 3.9.12
conda env list
# conda environments:
#
base * /home/doug/anaconda3
Looks like I'm in anaconda base env.
conda install psycopg2
Collecting package metadata (current_repodata.json): done
Solving environment: done
# All requested packages already installed.
Now, when I try to import:
Enter python terminal:
python
Python 3.9.12 (main, Apr 5 2022, 06:56:58)
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
Then try to import:
import psycopg2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2/__init__.py", line 50, in <module>
from psycopg2._psycopg import ( # noqa
ModuleNotFoundError: No module named 'psycopg2._psycopg'
It looks like /home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2 is masking what is installed into your base environment.
Try running this import from a different directory and/or delete /home/doug/Documents/Projects/Zen/Projects/data-scripts/ga4ExtractLoad/psycopg2.
See ModuleNotFoundError: No module named 'psycopg2._psycopg

Created a python package in TestPypi but I can't import it

I've deployed my first package in test.pypi.org as you can find it here
I have installed my package in my virtual environment (.venv).
$ pip list
returns :
Package Version
---------- -------
pip 20.1
pyupurs 0.0.2
setuptools 46.0.0
wheel 0.34.2
But as you can see here, I cannot import it within my interpreter.
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyupurs
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'pyupurs'
Why is this happening? How can I fix it?
In your package pyupurs there is nothing that can be imported under same name. The distribution package pyupurs installs top-level importable package named stateless_file_ops. So you can only do
import stateless_file_ops
If you want to change that you need to change you subdirectory structure perhaps adding a directory pyupurs with file __init__.py in it.

No module QtMultimedia [Mac OS - Anaconda - Python 3.7 - PyQt5]

I would like to play with QtMultimedia of PyQt5 but this does not work.
> conda list pyqt
# packages in environment at /anaconda3:
#
# Name Version Build Channel
pyqt 5.9.2 py37h655552a_2
> python
Python 3.7.0 (default, Jun 28 2018, 07:39:16)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda custom (64-bit) on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import PyQt5.QtMultimedia
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtMultimedia'
This looks like a bug.
Something strange : I have a file /anaconda3/lib/python3.7/site-packages/PyQt5/QtMultimediaWidgets.pyi which imports QtMultimedia but no QtMultimedia.pyi.
Can I easily fix this and what is the best way to report this bug ?
Use:
pip3 install pyqt5 --user
There is probably a conda equivalent, but this works for me in a conda environment without any problems. I presume that there is some permissions issue trying to install it for all users.
Indeed this was a bug from conda. I have made recently some updates that fixe my problem.

library referring to wrong version of Python

I have multiple pythons installed in my machine, 2.7, 3.5, 3.6, etc and I installed the library called spacy.
And it seems like this library keeps referring to the old version of python which is 3.5. at /usr/local/lib/python3.5/dist-packages.
Python 3.6.5 (default, Mar 29 2018, 03:28:50)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import spacy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/dist-packages/spacy/__init__.py", line 4, in <module>
from . import util
File "/usr/local/lib/python3.5/dist-packages/spacy/util.py", line 4, in <module>
import ujson
ModuleNotFoundError: No module named 'ujson'
Regardless of this specific library 'spacy', I'd like to know
what is the best way to make library to point to upgraded python which is 3.6, not 3.5. Which path variable should I update?
Please help... I've been wasting too much time on this issue.
Try to install spacy lib by running pip with required python version in module mode:
python3.6 -m pip install spacy

Unable to import pytables with intelpython

wonder if anyone has tried IntelPython with anaconda. i created an environment as in url link
Intel Python
however, when i try to import pytables, i get: -
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ python
Python 3.5.3 |Intel Corporation| (default, Apr 27 2017, 18:08:47)
[GCC 4.8.2 20140120 (Red Hat 4.8.2-15)] on linux
Type "help", "copyright", "credits" or "license" for more information.
Intel(R) Distribution for Python is brought to you by Intel Corporation.
Please check out: https://software.intel.com/en-us/python-distribution
>>> import tables
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'tables'
Which is strange because i have it running under the non-intel python environment, so i tried checking if pytables was installed under the intelpython environment
(intelpython) dc#dcpctw:/opt/anaconda3/bin$ sudo ./conda upgrade pytables
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /opt/anaconda3:
#
pytables 3.3.0 np112py35_intel_2 [intel] intel
(intelpython) dc#dcpctw:/opt/anaconda3/bin$
So its installed in the environment and should work, any help? thanks
You are running the python executable from /opt/anaconda/bin but you have an activated environment of (intelpython). Change to a different directory, e.g., ~, make sure the first python on your PATH is /opt/anaconda3/envs/intelpython/bin/python, and try the import again.

Categories

Resources