首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在python3.7中安装qutip软件包会产生错误

在python3.7中安装qutip软件包会产生错误
EN

Unix & Linux用户
提问于 2019-06-25 11:37:00
回答 2查看 1.5K关注 0票数 1

我正在使用Python3.7.3运行LinuxMint19.1,并试图安装qu技巧包。我已经安装了以下内容,因此应该满足依赖关系:

代码语言:javascript
复制
NumPy-1.16.4
SciPy-1.3.0
Maplotlib-3.1.0
Cython-0.29.10
GCC-8.0.1

我不确定Python Header依赖关系,但我运行了

代码语言:javascript
复制
sudo apt-get install python3.7-dev

没有错误,因为这是我在谷歌搜索时唯一能找到的东西。当我尝试使用qutip安装pip时,我得到了error: invalid command 'bdist_wheel'两次,Failed building wheel for py-postgresqlFailed to build qubit py-postgresql,之后它说安装成功了,请参见终端的完整打印:

代码语言:javascript
复制
$ python3.7 -m pip install qubit
Collecting qubit
  Using cached https://files.pythonhosted.org/packages/7e/fb/b9f75dba12698a1c394d9732d6d05008cc8a4d1d4854fc7201792e908626/qubit-0.0.1.tar.gz
Collecting Flask==0.11.1 (from qubit)
  Using cached https://files.pythonhosted.org/packages/63/2b/01f5ed23a78391f6e3e73075973da0ecb467c831376a0b09c0ec5afd7977/Flask-0.11.1-py2.py3-none-any.whl
Collecting py-postgresql==1.1.0 (from qubit)
  Using cached https://files.pythonhosted.org/packages/4c/cf/43d0287866f30f8b6f10ece19568fcda5477346c0f63bf5e9fb5c5eef121/py-postgresql-1.1.0.zip
Collecting pytest==3.0.3 (from qubit)
  Using cached https://files.pythonhosted.org/packages/a4/e9/bf75a9a91c4a545bad262937d1defa90d95ac912118a706406e21aef889a/pytest-3.0.3-py2.py3-none-any.whl
Collecting click>=2.0 (from Flask==0.11.1->qubit)
  Using cached https://files.pythonhosted.org/packages/fa/37/45185cb5abbc30d7257104c434fe0b07e5a195a6847506c074527aa599ec/Click-7.0-py2.py3-none-any.whl
Collecting Jinja2>=2.4 (from Flask==0.11.1->qubit)
  Using cached https://files.pythonhosted.org/packages/1d/e7/fd8b501e7a6dfe492a433deb7b9d833d39ca74916fa8bc63dd1a4947a671/Jinja2-2.10.1-py2.py3-none-any.whl
Collecting Werkzeug>=0.7 (from Flask==0.11.1->qubit)
  Using cached https://files.pythonhosted.org/packages/9f/57/92a497e38161ce40606c27a86759c6b92dd34fcdb33f64171ec559257c02/Werkzeug-0.15.4-py2.py3-none-any.whl
Collecting itsdangerous>=0.21 (from Flask==0.11.1->qubit)
  Using cached https://files.pythonhosted.org/packages/76/ae/44b03b253d6fade317f32c24d100b3b35c2239807046a4c953c7b89fa49e/itsdangerous-1.1.0-py2.py3-none-any.whl
Collecting py>=1.4.29 (from pytest==3.0.3->qubit)
  Using cached https://files.pythonhosted.org/packages/76/bc/394ad449851729244a97857ee14d7cba61ddb268dce3db538ba2f2ba1f0f/py-1.8.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask==0.11.1->qubit)
  Using cached https://files.pythonhosted.org/packages/98/7b/ff284bd8c80654e471b769062a9b43cc5d03e7a615048d96f4619df8d420/MarkupSafe-1.1.1-cp37-cp37m-manylinux1_x86_64.whl
Building wheels for collected packages: qubit, py-postgresql
  Running setup.py bdist_wheel for qubit ... error
  Complete output from command /usr/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-bohuey6f/qubit/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpy8xqxz6ipip-wheel- --python-tag cp37:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for qubit
  Running setup.py clean for qubit
  Running setup.py bdist_wheel for py-postgresql ... error
  Complete output from command /usr/bin/python3.7 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-bohuey6f/py-postgresql/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/tmpl3nlfezopip-wheel- --python-tag cp37:
  usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
     or: -c --help [cmd1 cmd2 ...]
     or: -c --help-commands
     or: -c cmd --help

  error: invalid command 'bdist_wheel'

  ----------------------------------------
  Failed building wheel for py-postgresql
  Running setup.py clean for py-postgresql
Failed to build qubit py-postgresql
Installing collected packages: click, MarkupSafe, Jinja2, Werkzeug, itsdangerous, Flask, py-postgresql, py, pytest, qubit
  Running setup.py install for py-postgresql ... done
  Running setup.py install for qubit ... done
Successfully installed Flask-0.11.1 Jinja2-2.10.1 MarkupSafe-1.1.1 Werkzeug-0.15.4 click-7.0 itsdangerous-1.1.0 py-1.8.0 py-postgresql-1.1.0 pytest-3.0.3 qubit-0.0.1
In ~/.local/lib/python3.7/site-packages

然后,我可以在qutip中看到两个名为~/.local/lib/python3.7/site-packagesqutip-4.3.1-py3.7.egg-info的目录,但是如果我运行python3.7并尝试为名为IndexMixin的东西import qutip ImportError,为apt_pkg设置ModuleNotFoundError,请参见完整的打印输出。

代码语言:javascript
复制
$ python3.7
Python 3.7.3 (default, Apr  3 2019, 19:16:38) 
[GCC 8.0.1 20180414 (experimental) [trunk revision 259383]] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import qutip
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/__init__.py", line 171, in 
    from qutip.qobj import *
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/qobj.py", line 60, in 
    from qutip.fastsparse import fast_csr_matrix, fast_identity
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/fastsparse.py", line 37, in 
    from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
ImportError: cannot import name 'IndexMixin' from 'scipy.sparse.sputils' (/home/kajsa/.local/lib/python3.7/site-packages/scipy/sparse/sputils.py)
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in 
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in 
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in 
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 24, in 
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in 
    import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "", line 1, in 
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/__init__.py", line 171, in 
    from qutip.qobj import *
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/qobj.py", line 60, in 
    from qutip.fastsparse import fast_csr_matrix, fast_identity
  File "/home/kajsa/.local/lib/python3.7/site-packages/qutip/fastsparse.py", line 37, in 
    from scipy.sparse.sputils import (upcast, upcast_char, to_native, isdense, isshape,
ImportError: cannot import name 'IndexMixin' from 'scipy.sparse.sputils' (/home/kajsa/.local/lib/python3.7/site-packages/scipy/sparse/sputils.py)
>>> 

有什么原因吗?

EN

回答 2

Unix & Linux用户

回答已采纳

发布于 2019-06-26 08:11:03

多亏@Bart,我成功地解决了所有的错误代码。我就是这么做的。

根据error: invalid command 'bdist_wheel'的说法,安装错误D0Failed building wheel for py-postgresqlFailed to build qubit py-postgresql都是通过安装wheel解决的。总之,我只是跑了

代码语言:javascript
复制
python3.7 -m pip install wheel
python3.7 -m pip install --upgrade --force-reinstall qutip

ImportError: cannot import name 'IndexMixin' from 'scipy.sparse.sputils' (/home/kajsa/.local/lib/python3.7/site-packages/scipy/sparse/sputils.py)的问题是由于最新版本中的due包发生了变化。根据这一讨论的说法,这不仅仅是一个举动,而是对软件包的改变,所以我不得不安装一个旧版本的had。这是通过运行这些命令来完成的。

代码语言:javascript
复制
python3.7 -m pip uninstall scipy
python3.7 -m pip install scipy<1.3.0

最后,通过跟踪ModuleNotFoundError: No module named 'apt_pkg',解决了这个答案和评论问题。通过跑

代码语言:javascript
复制
sudo apt-get install --reinstall python3-apt
cd /usr/lib/python3/dist-packages
sudo ln -s apt_pkg.cpython-{36m,37m}-x86_64-linux-gnu.so

注意:如果您发现有一个错误,如

代码语言:javascript
复制
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'RECORD'
Consider using the `--user` option or check the permissions.

我假设您可以通过添加--user标志来解决这个问题,或者像我所做的那样,使用sudo -H作为根用户运行它。

代码语言:javascript
复制
sudo -H python3.7 -m pip install 'scipy<1.3.0'
票数 1
EN

Unix & Linux用户

发布于 2019-06-25 12:38:11

票数 1
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/526818

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档