Python2.7: No module named zlib - python

I'm trying to use matplotlib in Python 2.7, but am encountering the following error
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/__init__.py", line 156, in <module>
File "/usr/lib/pymodules/python2.7/matplotlib/cbook.py", line 15, in <module>
File "/usr/local/lib/python2.7/gzip.py", line 9, in <module>
import zlib
ImportError: No module named zlib
I installed python with sudo apt-get install python2.7, and other required packages similarly. I installed zlib from source, with no issues.

Related

AttributeError: module 'dbus' has no attribute 'lowlevel'

Error Message:
Traceback (most recent call last):
File "/home/upboard/visioonbot/Connect4Py/connect4.py", line 7, in <module>
import dbus
File "/home/upboard/visioonbot/Connect4Py/venv/lib/python3.6/site-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/home/upboard/visioonbot/Connect4Py/venv/lib/python3.6/site-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
File "/home/upboard/visioonbot/Connect4Py/venv/lib/python3.6/site-packages/_dbus_bindings/__init__.py", line 13, in <module>
import dbus.lowlevel as __dbus_lowlevel
File "/home/upboard/visioonbot/Connect4Py/venv/lib/python3.6/site-packages/dbus/lowlevel.py", line 32, in <module>
from _dbus_bindings import (
File "/home/upboard/visioonbot/Connect4Py/venv/lib/python3.6/site-packages/_dbus_bindings/ErrorMessage.py", line 13, in <module>
import dbus.lowlevel as __dbus_lowlevel
AttributeError: module 'dbus' has no attribute 'lowlevel'
Process finished with exit code 1
Here are the dbus files mentioned in the error path:
and the dbus_bindings files:
What is missing? How to solve this issue?
I've already reinstalled the packages using
sudo apt install python3-dbus
and
sudo apt-get install -y python-dbus
It looks like your issue might be that you are using a venv. python3-dbus does not play nicely with venv's.
You can try using --system-site-packages as suggested in https://stackoverflow.com/a/13367493/7721752.
Or use pydbus and vext.gi

how to fix' no module name: object_objection.box_coders'?

ModuleNotFoundError on object-detection
Error StackTrace
Traceback (most recent call last):
File "train.py", line 58, in <module>
from object_detection.builders import model_builder
File "C:\Program Files\Python37\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\model_builder.py", line 21, in <module>
from object_detection.builders import box_coder_builder
File "C:\Program Files\Python37\lib\site-packages\object_detection-0.1-py3.7.egg\object_detection\builders\box_coder_builder.py", line 17, in <module>
from object_detection.box_coders import faster_rcnn_box_coder
ModuleNotFoundError: No module named 'object_detection.box_coders'
Seems your package is broken. Try reinstall it:
pip install --force-reinstall object-detection
Also see the docs's requires:
Requires: Python >=3.5, !=3.7.*
It only works with Python>=3.5 but no Python 3.7.*, so it doesn't work with your current Python. Consider install Python 3.5 and it should e fine.

Python + RaspberryPI can't import GPIO after installing: ImportError: No module named _GPIO

I have a RPi 2 (running raspbian jessie with pixel) and just tried to install the GPIO module:
I have downloaded and installed from source. Then I issue commands:
pi#raspberry:python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
so then I tried using sudo:
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using pip:
pi#raspberry:sudo pip install RPi.GPIO
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
Then I removed the module from python, and installed it again using apt-get:
pi#raspberry:sudo apt-get update
pi#raspberry:sudo apt-get -y install python-rpi.gpio
pi#raspberry:sudo python
>>> import RPi.GPIO as GPIO
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "RPi/GPIO/__init__.py", line 23, in <module>
from RPi._GPIO import *
ImportError: No module named _GPIO
It seems it has nothing to do with the install method, so I'm assuming it's something to do with either Raspbian Jessie + pixel or the current version of python-gpio is broken/incompatible.
Its strange because I am not importing "_GPIO", I am importing "GPIO", which indicates to me that my python syntax is not the culprit.
Could somebody please recommend what I should try next?
Also I searched this exact error on Google and got 1 result which was not helpful.
Thanks,
i think you have a dir called RPi in your current dir,so change your python file to another dir which doesn't have ,it works for me...hope it's helpful :)

python3 and RO package and DS9

How to get RO package working in Python 3? I managed to get it to work in Python 2.7, but when I install it manually as python3 setup.py install and then do import RO.DS9 I get this:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/DS9.py", line 160, in <module>
import RO.OS
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/__init__.py", line 7, in <module>
from .OSUtil import *
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/OS/OSUtil.py", line 31, in <module>
import RO.SeqUtil
File "/usr/local/lib/python3.4/dist-packages/RO-3.6.9-py3.4.egg/RO/SeqUtil.py", line 33, in <module>
import UserString
ImportError: No module named 'UserString'
>>> exit()
In Python 3, UserString is part of the collections module.
As you can see on the RO page, this library does only support Python 2.6 and 2.7.

python USER_BASE error

I am using python 2.6 and trying to install django tagging package and i get this error below.I am installing few python 2.4 packages on a 64 bit machine which already has python2.6.
How to resolve this error
[root#tom django-tagging-0.3.1]# python setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT 1
[root#tom django-tagging-0.3.1]# python2.6 setup.py install
Traceback (most recent call last):
File "setup.py", line 5, in <module>
from distutils.command.install import INSTALL_SCHEMES
File "/usr/lib64/python2.6/distutils/command/install.py", line 21, in <module>
from site import USER_BASE
ImportError: cannot import name USER_BASE
EDIT2
>>> from distutils.sysconfig import get_python_lib
>>> print(get_python_lib())
/usr/lib/python2.6/site-packages
EDIT3
>>> import site ; print site
<module 'site' from '/opt/mysite/site/__init__.pyc'>
You've called one of your Django apps "site". This is shadowing the site module in the stdlib. Rename it.

Categories

Resources