我正在尝试在Anaconda python环境中安装dbus,我正在努力。
以下是我收到的错误消息:
e@gateway:~$ python
Python 3.5.4 |Anaconda custom (64-bit)| (default, Oct 13 2017, 11:22:58)
[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/e/anaconda3/lib/python3.5/site-packages/dbus/__init__.py", line 77, in <module>
import dbus.types as types
File "/home/e/anaconda3/lib/python3.5/site-packages/dbus/types.py", line 6, in <module>
from _dbus_bindings import (
ImportError: /home/e/anaconda3/lib/python3.5/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
>>>
以下是我认为可能会被问到的一些输出:
e@gateway:~$ conda install dbus
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/e/anaconda3:
#
dbus 1.10.22 h3b5a359_0
e@gateway:~$ sudo apt-get install libdbus-glib-1-dev libdbus-1-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
libdbus-glib-1-dev is already the newest version (0.106-1).
libdbus-1-dev is already the newest version (1.10.6-1ubuntu3.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
e@gateway:~$ sudo apt-get install dbus
Reading package lists... Done
Building dependency tree
Reading state information... Done
dbus is already the newest version (1.10.6-1ubuntu3.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
e@gateway:~$ which python
/home/e/anaconda3/bin/python
e@gateway:~$ conda --version
conda 4.3.31
e@gateway:~$ sudo /home/e/anaconda3/bin/python -m pip install dbus-python
The directory '/home/e/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/e/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: dbus-python in ./anaconda3/lib/python3.5/site-packages
DBus在系统python上工作正常,但不能在Anaconda Python上工作。
Python 2.7:
e@gateway:~$ which python
/usr/bin/python
e@gateway:~$ python
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>>
Python 3.5:
e@gateway:~$ which python3
/usr/bin/python3
e@gateway:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import dbus
>>>
任何人都可以帮助我吗?我错过了一些明显明显的东西吗?
提前致谢。
答案 0 :(得分:0)
我有类似的问题,很少有dbus和python don't work well out-of-the-box的情况。共识似乎是您需要系统级安装(即apt-get
)才能使dbus正常工作。我相信您所看到的/home/e/anaconda3/lib/python3.5/site-packages/_dbus_bindings.so: undefined symbol: _Py_ZeroStruct
错误与此直接相关。
conda install dbus
不会向~/anaconda3/lib/python3.6/site-packages
添加任何内容,而是会在~/anaconda3/bin/
中安装一些可执行文件,例如dbus-run-session
,dbus-daemon
等。在分析dbus tarball https://anaconda.org/conda-forge/dbus的内容时感觉到,因为它是所有C文件和可执行文件。我不确定它应该是dbus
python模块,但我可能错了。
编辑:
我搜索了conda存储库并找到了一些上传了dbus-python版本的人,大概是他们编译和安装的。我通过以下方式在py3.6 conda环境中尝试this one:
conda install -c scottwales dbus-python
然后我能够导入dbus。这是一种hacky方法,不应该用于制作,我建议听 卡洛斯科尔多巴的帖子如下。但是,如果您现在需要解决方案,请搜索一些用户conda包或尝试自己编译库。
答案 1 :(得分:0)
任何人都可以帮助我吗?我错过了一些明显明显的东西吗?
是的,你是。人们仍然不了解conda
:[{1}} 不 conda
替代品。它是一个通用的包管理器,与pip
,apt-get
,yum
,brew
等相同,但是跨平台且基于Python。
在这种情况下,这意味着emerge
不会像{1 conda install dbus
那样安装Python Dbus绑定。它安装了Dbus C软件包本身,这是Qt 5所需要的(同样,C ++库,而不是Python的绑定)。
不幸的是,dbus-python
没有Conda包。更糟糕的是,似乎没有简单的方法为它创建包,正如here指出的那样。
最后,你说
以下是我收到的错误消息
该错误的(最可能的)原因是您将系统Python pip
路径添加到Anaconda的dist-packages
,或者因为您盲目地将PYTHONPATH
模块从系统Python复制到蟒蛇。请不要再这样做了。 System Python和Anaconda软件包使用不同的编译器并在不同的条件下编译。因此混合它们是造成难以理解的错误的原因,就像你报告的错误一样。