I am trying to use python-mbus for python 3, i have installed it with
sudo apt-get install python3-dbus
However the import fails with:
asdf#asdf:~$ python3
Python 3.6.3 (default, Oct 3 2017, 21:16:13)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/dist-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/usr/local/lib/python3.6/dist-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: /usr/local/lib/python3.6/dist-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
I have also installed it with:
pip3 uninstall dbus-python
But i still get the same error:
asdf#asdf:~$ python3
Python 3.6.3 (default, Oct 3 2017, 21:16:13)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/asdf/.local/lib/python3.6/site-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/home/asdf/.local/lib/python3.6/site-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: /home/asdf/.local/lib/python3.6/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
This is in sys.path:
>>> print (sys.path)
['', '/usr/lib/python36.zip', '/usr/lib/python3.6', '/usr/lib/python3.6/lib-dynload', '/home/asdf/.local/lib/python3.6/site-packages', '/usr/local/lib/python3.6/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.6/dist-packages']
Im runnin on Debian GNU/Linux buster/sid
Any idea of what am I doing wrong?
I'm not exactly sure how I fixed this (can't comment), but I had the exact same problem and I did:
sudo pip3 uninstall dbus-python
sudo aptitude update && sudo aptitude upgrade
sudo aptitude -f
After which aptitude alerted me of some dependency issues with Python, and I "downgraded" a version of Python I had installed on Ubuntu Xenial to the default package provided by Artful. Now, import dbus on Python 3.6.3 doesn't pass any errors. Don't know if it actually works well, though.
Maybe you'll be able to fix it in a similar fashion, since Debian and Ubuntu packages are usually the same.
Related
I want to install a package called Xsequence https://github.com/fscarlier/xsequence
in Windows vie git clone command and then I used python to install it
git clone https://github.com/fscarlier/xsequence.git
cd xsequence_master
python setup.py install
I have several python versions installed, put the one that was used in the installation was in the first path.
C:\Users\musa\AppData\Local\Programs\Python\Python310\python.exe
C:\Users\musa\Anaconda3\python.exe
C:\Users\musa\AppData\Local\Microsoft\WindowsApps\python.exe
The issue is that when I import the package Xsequence it works fine,
But when I try to import any other module from inside this package it doesn't work
Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import xsequence
>>> from xsequence.lattice import Lattice
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\musa\AppData\Local\Programs\Python\Python310\lib\site-packages\xsequence-0.0.0-py3.10.egg\xsequence\lattice.py", line 11, in <module>
File "C:\Users\musa\AppData\Local\Programs\Python\Python310\lib\site-packages\xsequence-0.0.0-py3.10.egg\xsequence\elements.py", line 13, in <module>
ModuleNotFoundError: No module named 'xsequence.helpers'
I checked the package folder manually it contains the module Xsequence.helper.
The strange thing that all the module can be imported if I run python directly after instilling the setp.py but once I closed the terminal its not imported anymore
I installed Docker on raspberry PI 3b. I want to configure a Python image with Mediapipe.
The basic image is demosense/raspberrypi3-opencv.
The way I installed mediapipe is
apt-get update
apt update
apt-get update
pip install mediapipe-rpi3 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
And then I realized that there was this mistake
root#ce01ec797bf6:/# python
Python 3.6.4 (default, Feb 13 2018, 04:59:47)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> import mediapipe
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/mediapipe/__init__.py", line 16, in <module>
from mediapipe.python import *
File "/usr/local/lib/python3.6/site-packages/mediapipe/python/__init__.py", line 17, in <module>
from mediapipe.python._framework_bindings import resource_util
ModuleNotFoundError: No module named 'mediapipe.python._framework_bindings'
Yesterday updated my ubuntu 17.04 to ubuntu 17.10. any comments? Appear when I try to run server in pycharm. #django project.
bash -cl "/home/encuentrum/venv-encuentrum3/bin/python /usr/share/pycharm/helpers/pycharm/django_manage.py check /home/encuentrum/GitLab/encuentrum3/ENCUENTRUM/packers_"
Traceback (most recent call last):
File "/usr/share/pycharm/helpers/pycharm/django_manage.py", line 5, in <module>
from pycharm_run_utils import adjust_django_sys_path
File "/usr/share/pycharm/helpers/pycharm/pycharm_run_utils.py", line 4, in <module>
import imp
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/imp.py", line 19, in <module>
from importlib._bootstrap import _ERR_MSG, _exec, _load, _builtin_from_name
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/importlib/__init__.py", line 57, in <module>
import types
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/types.py", line 171, in <module>
import functools as _functools
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/home/encuentrum/venv-encuentrum3/lib/python3.6/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
Maybe you have mixed your multiple Python installations, the newer version of weakref are not compatible with older version python binary, try to remove any one (the older one is recommended) of Python installation.
Analysis
For my case, I have installed older version Python (3.5.1) before, and upgrade my Debian installation. The newer Debian upgrade it's Python3.5 to 3.5.3 which have _remove_dead_weakref in _weakref in its Python binary
When I type $ where python3.5, I get
/usr/local/bin/python3.5
/usr/local/bin/python3.5
/usr/bin/python3.5
The /usr/local/bin/python3.5 is my own older installation, and /usr/bin/python3.5 is Debian offical Python3.5
When I update my Python3.5 installation by apt-get, apt-get execute python3.5 -E -S /usr/lib/python3.5/py_compile.py $files (post-install script) in the deb package.`, it triggers the weakref issue, here is my log
Setting up python3.5-minimal (3.5.3-1+deb9u1) ...
Traceback (most recent call last):
File "/usr/lib/python3.5/py_compile.py", line 6, in <module>
import importlib._bootstrap_external
File "/usr/lib/python3.5/importlib/__init__.py", line 57, in <module>
import types
File "/usr/lib/python3.5/types.py", line 166, in <module>
import functools as _functools
File "/usr/lib/python3.5/functools.py", line 23, in <module>
from weakref import WeakKeyDictionary
File "/usr/lib/python3.5/weakref.py", line 12, in <module>
from _weakref import (
ImportError: cannot import name '_remove_dead_weakref'
I tested Python 3.5.1 and Python 3.5.3 with same import action, here are the compares
Official Python 3.5.3 from apt-get
Python 3.5.3 (default, Sep 27 2018, 17:25:39)
[GCC 6.3.0 20170516] on linux
>>> from _weakref import _remove_dead_weakref
>>>
My own Python 3.5.1 installation
Python 3.5.1 (default, Apr 23 2016, 16:40:21)
[GCC 4.9.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from _weakref import _remove_dead_weakref
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name '_remove_dead_weakref'
>>>
So, I confirm that python3.5 in /usr/local/bin/ cannot use _remove_dead_weakref.
But which python did apt-get use in post-installation script? Try it.
$ which python3.5
/usr/local/bin/python3.5
So, here is why. The post-installation script use my custom installation of python, along with newer python library (/usr/lib/python3.5/weakref.py)
Fix it!
As I said, disable older version of python
sudo mv /usr/local/bin/python3.5 /usr/local/bin/python3.5.bak
Test
$ which python3.5
/usr/bin/python3.5
Adding to #Comzyh answer, this indeed is due to mixed python versions when an upgrade happen due to any reason. A quick fix is to remove your venv python binary i.e. rm <path-to-your-env>/bin/python and copying your system python binary to your venv like cp /usr/bin/python <path-to-your-env>/bin/python. This will fix the weak ref error
I have installed installed the following modules in my EC2 server which already has python (3.6) & anaconda installed :
snappy
pyarrow
s3fs
fastparquet
except fastparquet everything else works on importing. When I try to import fastparquet it throws the following error :
[username#ip8 ~]$ conda -V
conda 4.2.13
[username#ip-~]$ python
Python 3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 12:22:00)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import fastparquet
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/__init__.py", line 15, in <module>
from .core import read_thrift
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/core.py", line 11, in <module>
from .compression import decompress_data
File "/home/username/anaconda3/lib/python3.6/site-packages/fastparquet/compression.py", line 43, in <module>
compressions['SNAPPY'] = snappy.compress
AttributeError: module 'snappy' has no attribute 'compress'
How do I go about fixing this ?
Unfortunately, there are multiple things in python-land called "snappy". I believe you may have the wrong one, in which case one of the following conda commands should solve this for you:
conda install python-snappy
or
conda install python-snappy -c conda-forge
where the latter is slightly more recent (releases the GIL which can be important in threaded applications).
I cant import rdflib in python. error detailed:
Python 2.7.3 (default, Jun 27 2012, 23:48:21)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import rdflib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/rdflib/__init__.py", line 65, in <module>
from rdflib.term import URIRef, BNode, Literal, Variable
File "/usr/local/lib/python2.7/site-packages/rdflib/term.py", line 49, in <module>
from isodate import parse_time, parse_date, parse_datetime
ImportError: No module named isodate
I would be grateful if anybody can help.
Thanks.
If you actually install rdflib via pip, then its dependencies will come along with it (isodate included):
pip install -U rdflib
or
easy_install -U rdflib
Chances are you might have installed it directly from source, meaning you would have to take care of the deps yourself.
Information on installing pip if you dont have it already:
http://www.pip-installer.org/en/latest/installing.html
If you have easy_install, you can do: easy_install pip
It seems there is a dependency to isodate, so try installing that via your favorite PyPI-Installer (pip oder *easy_install*).