Python Openfermion软件包-找不到模块错误 [英] Python Openfermion Package - Module not found errors

查看:127
本文介绍了Python Openfermion软件包-找不到模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个脚本,该脚本尤其依赖于Google的Openfermion软件包.我也在使用QuTiP,PySCF和Openfermion-PySCF.

I'm trying to run a script that, among other things, relies on the Openfermion package from Google. I'm also using QuTiP, PySCF, and Openfermion-PySCF.

在尝试运行脚本时,根据我的安装方法,我会遇到很多错误.

When trying to run my script I've gotten a slew of errors, depending on my method of installation.

我用 Python == 3.7 创建了一个Python环境.当我在版本0.9.0(使用 conda install -c psi4 openfermion 安装)上使用Openfermion时,出现错误

I've created a Python environment with Python==3.7. When I use Openfermion on version 0.9.0 (having installed with conda install -c psi4 openfermion) I get the error

Traceback (most recent call last):
  File "main.py", line 6, in <module>
    from setupFunc import *
  File "/home/anders/Documents/setupFunc.py", line 5, in <module>
    from moleculeClass import *
  File "/home/anders/Documents/moleculeClass.py", line 9, in <module>
    from openfermionpyscf import run_pyscf
  File "/home/anders/.local/lib/python3.7/site-packages/openfermionpyscf/__init__.py", line 17, in <module>
    from ._pyscf_molecular_data import PyscfMolecularData
  File "/home/anders/.local/lib/python3.7/site-packages/openfermionpyscf/_pyscf_molecular_data.py", line 20, in <module>
    from openfermion.chem import MolecularData
ModuleNotFoundError: No module named 'openfermion.chem'

-pip show openfermion 的(当前)输出为;

The (current) output from -pip show openfermion is;

Name: openfermion
Version: 0.9.0
Summary: The electronic structure package for quantum computers.
Home-page: http://www.openfermion.org
Author: The OpenFermion Developers
Author-email: help@openfermion.org
License: Apache 2
Location: /home/anders/anaconda3/envs/vqeenv/lib/python3.7/site-packages
Requires: numpy, scipy, h5py, future, jupyter, nbformat, networkx, matplotlib, pubchempy, six
Required-by: openfermionpyscf

如果我使用pip进行安装,即 python -m pip install --user openfermion ,则会收到相同的错误.我也尝试过使用Openfermion == 0.10.0和0.11.0,并且曾经使用1.0.0版本-但在每种情况下,它们都给出相同类型的错误;找不到模块-尽管在某些情况下它指向 openfermion.hamiltonians ,而不是 openfermion.chem .

If I install using pip, i.e. python -m pip install --user openfermion, I get the same error. I've also tried using Openfermion==0.10.0 and 0.11.0, and once a version 1.0.0 - but in every case they give the same type of error; of a module not found - although in some cases it points to openfermion.hamiltonians, rather than openfermion.chem.

在某些版本上,我还会收到无法从scipy.misc导入梳子"的错误消息.-但我知道如何解决.

On some versions I also get an error of "failing to import comb, from scipy.misc" - but I know how to fix that.

要复制我的问题,请尝试使用以下内容创建环境;

To replicate my issue, try creating an env with the following;

# This file may be used to create an environment using:
# $ conda create --name <env> --file spec-vqe-hp.txt
# platform: linux-64
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2019.11.28-hecc5488_0.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/intel-openmp-2020.0-166.conda
https://conda.anaconda.org/conda-forge/linux-64/ld_impl_linux-64-2.33.1-h53a641e_8.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libgfortran-3.0.0-1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libgfortran-ng-7.3.0-hdf63c60_5.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libstdcxx-ng-9.2.0-hdf63c60_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libgomp-9.2.0-h24d8f2e_2.tar.bz2
https://repo.anaconda.com/pkgs/main/linux-64/mkl-2020.0-166.conda
https://conda.anaconda.org/conda-forge/linux-64/_openmp_mutex-4.5-0_gnu.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libgcc-ng-9.2.0-h24d8f2e_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/expat-2.2.9-he1b5a44_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/fftw-3.3.8-nompi_h7f3a6c3_1110.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/gmp-6.2.0-he1b5a44_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/icu-64.2-he1b5a44_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/jpeg-9c-h14c3975_1001.tar.bz2
https://conda.anaconda.org/pyscf/linux-64/libcint-3.0.19-0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libffi-3.2.1-he1b5a44_1006.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libiconv-1.15-h516909a_1005.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libllvm9-9.0.1-hc9558a2_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libopenblas-0.3.7-h5ec1e0e_6.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libuuid-2.32.1-h14c3975_1000.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libxc-4.3.4-h6e990d7_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libxkbcommon-0.10.0-he1b5a44_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/metis-5.1.0-he1b5a44_1005.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/ncurses-6.1-hf484d3e_1002.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/nspr-4.25-he1b5a44_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/openssl-1.1.1d-h516909a_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/pcre-8.43-he1b5a44_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/pthread-stubs-0.4-h14c3975_1001.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/tbb-2019.9-hc9558a2_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/xorg-libxau-1.0.9-h14c3975_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/xorg-libxdmcp-1.1.3-h516909a_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/xz-5.2.4-h14c3975_1001.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/zlib-1.2.11-h516909a_1006.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/gettext-0.19.8.1-hc5be6a0_1002.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/glpk-4.65-he80fd80_1002.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/hdf5-1.10.2-hc401514_3.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libblas-3.8.0-14_openblas.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libclang-9.0.1-default_hde54327_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libpng-1.6.37-hed695b0_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libxcb-1.13-h14c3975_1002.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libxml2-2.9.10-hee79883_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/readline-8.0-hf8c457e_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/tk-8.6.10-hed695b0_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/freetype-2.10.0-he983fc9_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/libcblas-3.8.0-14_openblas.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/liblapack-3.8.0-14_openblas.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/sqlite-3.30.1-hcee41ef_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/dsdp-5.8-h23d7751_1203.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/fontconfig-2.13.1-h86ecdb6_1001.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/gsl-2.6-h294904e_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/nss-3.47-he751ad9_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/python-3.7.6-h357f687_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/suitesparse-5.6.0-h717dc36_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/certifi-2019.11.28-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/cvxopt-1.2.4-py37h93fb107_202.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/cython-0.29.14-py37he1b5a44_0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/decorator-4.4.1-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/future-0.18.2-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/glib-2.58.3-py37h6f030ca_1002.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/kiwisolver-1.1.0-py37hc9558a2_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/numpy-1.18.1-py37h95a1406_0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/pyparsing-2.4.6-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/six-1.14.0-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/tornado-6.0.3-py37h516909a_2.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/cycler-0.10.0-py_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/dbus-1.13.6-he372182_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/gstreamer-1.14.5-h36ae1b5_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/h5py-2.8.0-py37h3010b51_1003.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/python-dateutil-2.8.1-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/scipy-1.4.1-py37h921218d_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/setuptools-45.2.0-py37_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/gst-plugins-base-1.14.5-h0935bb2_1.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/joblib-0.14.1-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/matplotlib-base-3.1.3-py37h250f245_0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/networkx-2.4-py_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/numexpr-2.7.1-py37hb3f55d8_0.tar.bz2
https://conda.anaconda.org/pyscf/linux-64/pyscf-1.7.0-py37h39e3cac_0.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/qutip-4.5.0-py37h9de70de_0.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/wheel-0.34.2-py_1.tar.bz2
https://conda.anaconda.org/psi4/linux-64/openfermion-0.9-py37hd763080_1.tar.bz2
https://conda.anaconda.org/conda-forge/noarch/pip-20.0.2-py_2.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/qt-5.12.5-hd8c4c69_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/scikit-learn-0.22.1-py37hcdab131_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/pyqt-5.12.3-py37hcca6a23_1.tar.bz2
https://conda.anaconda.org/conda-forge/linux-64/matplotlib-3.1.3-py37_0.tar.bz2

p.s.我正在Windows 7的虚拟机上运行64位Linux(Ubuntu),并且正在使用conda 4.9.2.

p.s. I am running Linux (Ubuntu) 64-bit on a virtual machine from Windows 7, and am using conda 4.9.2.

推荐答案

以下步骤用于正确设置Conda环境:

The following steps are for setting up your Conda environment properly:

第1步:创建并激活新的Conda环境(您可以将 test 替换为您的首选名称)

Step 1: Create and activate a new Conda environment (You can replace test by your preferred name)

conda create -n test python=3.7 -y
conda activate test

第2步:安装最新的 openfermion openfermionpyscf pyscf

Step 2: Install the latest openfermion, openfermionpyscf and pyscf

pip install -U openfermion openfermionpyscf pyscf

第3步:测试

$ python                                                                                                                                                                                                                
Python 3.7.10 (default, Feb 26 2021, 10:16:00) 
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import openfermion
>>> import openfermionpyscf
>>> from openfermionpyscf import run_pyscf
>>> import pyscf

如果此步骤没有错误,那么您应该可以运行代码.

If there is no error in this step then you should be able to run your code.

注意:答案会根据后续讨论进行更新.

NOTE: Answer is updated based on the follow-up discussion.

这篇关于Python Openfermion软件包-找不到模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆