错误:失败:ModuleNotFoundError(没有名为“ atoms”的模块)

时间:2018-07-14 23:29:52

标签: python bash git github

我正在尝试使用git.bash从github运行一些测试-https://github.com/freude/NanoNet-但是当我运行鼻子测试时,我遇到了 ERROR:Failure:ModuleNotFoundError(没有名为“ atoms”的模块) )

我正在运行python 3.7.0,win8(64位)。我不太确定如何解决这个问题。任何帮助将不胜感激。

Sammy@Sam MINGW64 /
$ cd /c/users/sammy/desktop/nanonet/test

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$ nosetests --with-doctest
C:\users\sammy\desktop\nanonet\test\test_hamiltonian_module.py:22: SyntaxWarning: assertion is always true, perhaps remove parentheses?
  assert (h.is_hermitian(), True)
C:\users\sammy\desktop\nanonet\test\test_hamiltonian_module.py:64: SyntaxWarning: assertion is always true, perhaps remove parentheses?
  assert(h.is_hermitian(), True)
EEEE
======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'atoms')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python37\lib\site-packages\nose\failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "c:\python37\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\python37\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\python37\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "c:\python37\lib\imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "c:\python37\lib\imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\users\sammy\desktop\nanonet\test\test_aux_functions.py", line 2, in <module>
    from tb.aux_functions import xyz2np
  File "C:\users\sammy\desktop\nanonet\tb\__init__.py", line 7, in <module>
    from atoms import Atom
ModuleNotFoundError: No module named 'atoms'
-------------------- >> begin captured logging << --------------------
matplotlib: DEBUG: $HOME=C:\Users\Sammy
matplotlib: DEBUG: matplotlib data path c:\python37\lib\site-packages\matplotlib\mpl-data
matplotlib: DEBUG: loaded rc file c:\python37\lib\site-packages\matplotlib\mpl-data\matplotlibrc
matplotlib: DEBUG: matplotlib version 2.2.2
matplotlib: DEBUG: interactive is False
matplotlib: DEBUG: platform is win32
matplotlib: DEBUG: loaded modules: ['sys', 'builtins', '_frozen_importlib', '_imp', '_thread', '_warnings', '_weakref', 'zipimport', '_frozen_importlib_external', '_io', 'marshal', 'nt', 'winreg', 'encodings', 'codecs', '_codecs', 'encodings.aliases', 'encodings.utf_8', '_signal', 'encodings.latin_1', 'io', 'abc', '_abc', '_bootlocale', '_locale', 'encodings.cp1252', 'site', 'os', 'stat', '_stat', 'ntpath', 'genericpath', 'os.path', '_collections_abc', '_sitebuiltins', 'types', 'importlib', 'importlib._bootstrap', 'importlib._bootstrap_external', 'warnings', 'importlib.util', 'importlib.abc', 'importlib.machinery', 'contextlib', 'collections', 'operator', '_operator', 'keyword', 'heapq', '_heapq', 'itertools', 'reprlib', '_collections', 'functools', '_functools', 'mpl_toolkits', 'encodings.cp437', 'runpy', 'pkgutil', 'weakref', '_weakrefset', '__main__', 're', 'enum', 'sre_compile', '_sre', 'sre_parse', 'sre_constants', 'copyreg', 'nose', 'nose.core', 'logging', 'time', 'traceback', 'linecache', 'tokenize', 'token', 'collections.abc', 'string', '_string', 'threading', 'atexit', 'unittest', 'unittest.result', 'unittest.util', 'unittest.case', 'difflib', 'pprint', 'unittest.suite', 'unittest.loader', 'fnmatch', 'posixpath', 'unittest.main', 'argparse', 'gettext', 'locale', 'unittest.runner', 'unittest.signals', 'signal', 'nose.config', 'optparse', 'textwrap', 'errno', 'configparser', 'nose.util', 'inspect', 'dis', 'opcode', '_opcode', 'nose.pyversion', 'nose.plugins', 'nose.plugins.base', 'nose.plugins.manager', 'nose.failure', 'pickle', 'struct', '_struct', '_compat_pickle', '_pickle', 'pkg_resources', '__future__', 'zipfile', 'shutil', 'zlib', 'bz2', '_compression', '_bz2', 'lzma', '_lzma', 'binascii', 'platform', 'subprocess', 'msvcrt', '_winapi', 'plistlib', 'datetime', 'math', '_datetime', 'xml', 'xml.parsers', 'xml.parsers.expat', 'pyexpat.errors', 'pyexpat.model', 'pyexpat', 'xml.parsers.expat.model', 'xml.parsers.expat.errors', 'email', 'email.parser', 'email.feedparser', 'email.errors', 'email._policybase', 'email.header', 'email.quoprimime', 'email.base64mime', 'base64', 'email.charset', 'email.encoders', 'quopri', 'email.utils', 'random', 'hashlib', '_hashlib', '_blake2', '_sha3', 'bisect', '_bisect', '_random', 'socket', '_socket', 'selectors', 'select', 'urllib', 'urllib.parse', 'email._parseaddr', 'calendar', 'tempfile', 'pkg_resources.extern', 'pkg_resources._vendor', 'pkg_resources.extern.six', 'pkg_resources._vendor.six', 'pkg_resources.extern.six.moves', 'pkg_resources._vendor.six.moves', 'pkg_resources.py31compat', 'ctypes', '_ctypes', 'ctypes._endian', 'pkg_resources.extern.appdirs', 'pkg_resources._vendor.packaging.__about__', 'pkg_resources.extern.packaging', 'pkg_resources.extern.packaging.version', 'pkg_resources.extern.packaging._structures', 'pkg_resources.extern.packaging.specifiers', 'pkg_resources.extern.packaging._compat', 'pkg_resources.extern.packaging.requirements', 'copy', 'pkg_resources.extern.pyparsing', 'pkg_resources.extern.six.moves.urllib', 'pkg_resources.extern.packaging.markers', 'sysconfig', 'nose.plugins.plugintest', 'multiprocessing', 'multiprocessing.context', 'multiprocessing.process', 'multiprocessing.reduction', '__mp_main__', 'nose.loader', 'nose.case', 'nose.importer', 'imp', 'nose.selector', 'nose.suite', 'nose.proxy', 'nose.result', 'nose.exc', 'nose.plugins.skip', 'nose.plugins.errorclass', 'nose.plugins.deprecated', 'nose.tools', 'nose.tools.nontrivial', 'nose.tools.trivial', 'nose.plugins.builtin', 'nose.plugins.attrib', 'nose.plugins.capture', 'nose.plugins.logcapture', 'nose.plugins.cover', 'nose.plugins.debug', 'pdb', 'cmd', 'bdb', 'code', 'codeop', 'glob', 'nose.plugins.doctests', 'doctest', 'nose.plugins.isolate', 'nose.plugins.failuredetail', 'nose.inspector', 'nose.plugins.prof', 'nose.plugins.testid', 'nose.plugins.multiprocess', 'queue', '_queue', 'nose.plugins.xunit', 'xml.sax', 'xml.sax.xmlreader', 'xml.sax.handler', 'xml.sax._exceptions', 'xml.sax.saxutils', 'urllib.request', 'http', 'http.client', 'email.message', 'uu', 'email._encoded_words', 'email.iterators', 'ssl', '_ssl', 'urllib.error', 'urllib.response', 'nturl2path', 'nose.plugins.allmodules', 'nose.plugins.collect', 'test', 'test.test_greens_functions', 'matplotlib', 'six', 'distutils', 'distutils.version', 'distutils.sysconfig', 'distutils.errors', 'matplotlib.cbook', 'six.moves', 'gzip', 'numbers', 'numpy', 'numpy._globals', 'numpy.__config__', 'numpy.version', 'numpy._import_tools', 'numpy.add_newdocs', 'numpy.lib', 'numpy.lib.info', 'numpy.lib.type_check', 'numpy.core', 'numpy.core.info', 'numpy.core.multiarray', 'numpy.core.umath', 'numpy.core._internal', 'numpy.compat', 'numpy.compat._inspect', 'numpy.compat.py3k', 'pathlib', 'numpy.core.numerictypes', 'numpy.core.numeric', 'numpy.core.fromnumeric', 'numpy.core._methods', 'numpy.core.arrayprint', 'numpy.core.defchararray', 'numpy.core.records', 'numpy.core.memmap', 'numpy.core.function_base', 'numpy.core.machar', 'numpy.core.getlimits', 'numpy.core.shape_base', 'numpy.core.einsumfunc', 'numpy.testing', 'numpy.testing.decorators', 'numpy.testing.nose_tools', 'numpy.testing.nose_tools.decorators', 'numpy.testing.nose_tools.utils', 'numpy.lib.utils', 'numpy.testing.nosetester', 'numpy.testing.nose_tools.nosetester', 'numpy.testing.utils', 'numpy.lib.ufunclike', 'numpy.lib.index_tricks', 'numpy.lib.function_base', 'numpy.lib.twodim_base', 'numpy.matrixlib', 'numpy.matrixlib.defmatrix', 'ast', '_ast', 'numpy.lib.stride_tricks', 'numpy.lib.mixins', 'numpy.lib.nanfunctions', 'numpy.lib.shape_base', 'numpy.lib.scimath', 'numpy.lib.polynomial', 'numpy.linalg', 'numpy.linalg.info', 'numpy.linalg.linalg', 'numpy.linalg.lapack_lite', 'numpy.linalg._umath_linalg', 'numpy.lib.arraysetops', 'numpy.lib.npyio', 'numpy.lib.format', 'numpy.lib._datasource', 'numpy.lib._iotools', 'numpy.lib.financial', 'decimal', '_decimal', 'numpy.lib.arrayterator', 'numpy.lib.arraypad', 'numpy.lib._version', 'numpy._distributor_init', 'numpy.fft', 'numpy.fft.info', 'numpy.fft.fftpack', 'numpy.fft.fftpack_lite', 'numpy.fft.helper', 'numpy.polynomial', 'numpy.polynomial.polynomial', 'numpy.polynomial.polyutils', 'numpy.polynomial._polybase', 'numpy.polynomial.chebyshev', 'numpy.polynomial.legendre', 'numpy.polynomial.hermite', 'numpy.polynomial.hermite_e', 'numpy.polynomial.laguerre', 'numpy.random', 'numpy.random.info', 'cython_runtime', 'mtrand', 'numpy.random.mtrand', 'numpy.ctypeslib', 'numpy.ma', 'numpy.ma.core', 'numpy.ma.extras', 'matplotlib.cbook.deprecation', 'matplotlib.cbook._backports', 'matplotlib.compat', 'matplotlib.compat.subprocess', 'matplotlib.rcsetup', 'matplotlib.testing', 'matplotlib.fontconfig_pattern', 'pyparsing', 'matplotlib.colors', 'matplotlib._color_data', 'cycler', 'six.moves.urllib', 'six.moves.urllib.request', 'matplotlib._version', 'json', 'json.decoder', 'json.scanner', '_json', 'json.encoder', 'dateutil', 'dateutil._version']
matplotlib: DEBUG: CACHEDIR=C:\Users\Sammy\.matplotlib
matplotlib.font_manager: DEBUG: Using fontManager instance from C:\Users\Sammy\.matplotlib\fontList.json
matplotlib.backends: DEBUG: backend TkAgg version unknown
--------------------- >> end captured logging << ---------------------

======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'atoms')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python37\lib\site-packages\nose\failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "c:\python37\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\python37\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\python37\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "c:\python37\lib\imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "c:\python37\lib\imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\users\sammy\desktop\nanonet\test\test_greens_functions.py", line 4, in <module>
    import tb
  File "C:\users\sammy\desktop\nanonet\tb\__init__.py", line 7, in <module>
    from atoms import Atom
ModuleNotFoundError: No module named 'atoms'

======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'atoms')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python37\lib\site-packages\nose\failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "c:\python37\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\python37\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\python37\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "c:\python37\lib\imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "c:\python37\lib\imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\users\sammy\desktop\nanonet\test\test_hamiltonian_module.py", line 2, in <module>
    import tb
  File "C:\users\sammy\desktop\nanonet\tb\__init__.py", line 7, in <module>
    from atoms import Atom
ModuleNotFoundError: No module named 'atoms'

======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'atoms')
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python37\lib\site-packages\nose\failure.py", line 39, in runTest
    raise self.exc_val.with_traceback(self.tb)
  File "c:\python37\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\python37\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\python37\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "c:\python37\lib\imp.py", line 235, in load_module
    return load_source(name, filename, file)
  File "c:\python37\lib\imp.py", line 172, in load_source
    module = _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\users\sammy\desktop\nanonet\test\test_scripts_and_initializer.py", line 2, in <module>
    import tb.tb_script as tb_script
  File "C:\users\sammy\desktop\nanonet\tb\__init__.py", line 7, in <module>
    from atoms import Atom
ModuleNotFoundError: No module named 'atoms'

----------------------------------------------------------------------
Ran 4 tests in 0.000s

FAILED (errors=4)

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$

编辑:所以我卸载了重新启动的python3,然后安装了python2.7.15(64位)。我重新安装了requirements.txt依赖项,并进行了“ pip安装”。再次,但是这一次,当我尝试完成'nosetests --with-doctests'时,我得到一个'ImportError:DLL加载失败:找不到指定的模块。'

Sammy@Sam MINGW64 /
$ cd /c/

Sammy@Sam MINGW64 /c
$ python --version
Python 2.7.15

Sammy@Sam MINGW64 /c
$ cd /c/users/sammy/desktop/nanonet

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ ls
__pycache__/  get-pip.pyc         LICENSE      requirements.txt  tb.egg-info/
docs/         input_samples/      MANIFEST.in  setup.py          test/
get-pip.py*   jupyter_notebooks/  README.md    tb/

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ cd /test/
bash: cd: /test/: No such file or directory

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ cd /test
bash: cd: /test: No such file or directory

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ cd /c/users/sammy/desktop/nanonet/test

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$ nosetests --with-doctest
bash: nosetests: command not found

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$ cd /c/users/sammy/desktop/nanonet

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ pip install -r requirements.txt
Requirement already satisfied: setuptools in c:\python27\lib\site-packages (from -r requirements.txt (line 1))
Collecting matplotlib (from -r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/3f/a5/8e2ec9a471175be0239dbf8bc1f30d75a04a244e49e1c718e194dd45292e/matplotlib-2.2.2-cp27-cp27m-win_amd64.whl (8.4MB)
Collecting numpy==1.14.1 (from -r requirements.txt (line 3))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/3b/98/e5594863d96cf79bb89bb4f49191403136c08b8353c3e3ebcb17cc6554e3/numpy-1.14.1-cp27-none-win_amd64.whl (13.3MB)
Collecting scipy (from -r requirements.txt (line 4))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/d2/a7/0d698589a3c6c44f81078a52518c8e64c4ed579a862105b2bff5a1f14ff4/scipy-1.1.0-cp27-none-win_amd64.whl (31.5MB)
Collecting PyYAML (from -r requirements.txt (line 5))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/df/4d/1ef8d60464a171112401e17a3a3e88fdb1d5b44af7606e8652b2f39ee9ce/PyYAML-3.13-cp27-cp27m-win_amd64.whl (209kB)
Collecting nose (from -r requirements.txt (line 6))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/99/4f/13fb671119e65c4dce97c60e67d3fd9e6f7f809f2b307e2611f4701205cb/nose-1.3.7-py2-none-any.whl (154kB)
Collecting mpi4py (from -r requirements.txt (line 7))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/4d/14/4df0ba0247a94c93a227d99f7d0ffb7a06b0d33bc73460c5ea16ead5b800/mpi4py-3.0.0-cp27-cp27m-win_amd64.whl (489kB)
Collecting python-dateutil>=2.1 (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB)
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
Collecting pytz (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl (510kB)
Collecting backports.functools-lru-cache (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/03/8e/2424c0e65c4a066e28f539364deee49b6451f8fcd4f718fefa50cc3dcf48/backports.functools_lru_cache-1.5-py2.py3-none-any.whl
Collecting six>=1.10 (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting cycler>=0.10 (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting kiwisolver>=1.0.1 (from matplotlib->-r requirements.txt (line 2))
  Cache entry deserialization failed, entry ignored
  Downloading https://files.pythonhosted.org/packages/e0/3a/2fda27dacdfafcf8f40cce2be09890b1443af3e65c3ab8f7294216a2946b/kiwisolver-1.0.1-cp27-none-win_amd64.whl (64kB)
Installing collected packages: six, python-dateutil, pyparsing, numpy, pytz, backports.functools-lru-cache, cycler, kiwisolver, matplotlib, scipy, PyYAML, nose, mpi4py
Successfully installed PyYAML-3.13 backports.functools-lru-cache-1.5 cycler-0.10.0 kiwisolver-1.0.1 matplotlib-2.2.2 mpi4py-3.0.0 nose-1.3.7 numpy-1.14.1 pyparsing-2.2.0 python-dateutil-2.7.3 pytz-2018.5 scipy-1.1.0 six-1.11.0
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ pip install .
Processing c:\users\sammy\desktop\nanonet
Installing collected packages: tb
  Running setup.py install for tb: started
    Running setup.py install for tb: finished with status 'done'
Successfully installed tb-0.5
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet (master)
$ cd /c/users/sammy/desktop/nanonet/test

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$ nosetests --with-doctest
.........E
======================================================================
ERROR: Failure: ImportError (DLL load failed: The specified module could not be found.)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "c:\python27\lib\site-packages\nose\loader.py", line 418, in loadTestsFromName
    addr.filename, addr.module)
  File "c:\python27\lib\site-packages\nose\importer.py", line 47, in importFromPath
    return self.importFromDir(dir_path, fqname)
  File "c:\python27\lib\site-packages\nose\importer.py", line 94, in importFromDir
    mod = load_module(part_fqname, fh, filename, desc)
  File "C:\users\sammy\desktop\nanonet\test\test_scripts_and_initializer.py", line 3, in <module>
    import tb.tbmpi_script as tbmpi_script
  File "C:\users\sammy\desktop\nanonet\tb\tbmpi_script.py", line 3, in <module>
    from mpi4py import MPI
ImportError: DLL load failed: The specified module could not be found.

----------------------------------------------------------------------
Ran 10 tests in 5.382s

FAILED (errors=1)

Sammy@Sam MINGW64 /c/users/sammy/desktop/nanonet/test (master)
$

1 个答案:

答案 0 :(得分:0)

有问题的代码是为Python 2编写的;例如,文件tb/__init__.py包含以下行:

from atoms import Atom
from hamiltonian import Hamiltonian
from hamiltonian_sparse import HamiltonianSp
from aux_functions import get_k_coords, yaml_parser
from hamiltonian_initializer import set_tb_params, initializer

from greens_function import surface_greens_function

所有提到的模块都存在于tb/文件夹中,因此导入它们的正确方法是在其名称前面加上一个点(例如from .atoms import Atom);此处看到的旧的absolute_imports之前的旧导入方式仅适用于Python 2。

您的可以尝试重写代码以修复所有导入,但是几乎肯定会存在其他跨版本不兼容的情况。使代码运行的唯一肯定的方法是在Python 2而不是Python 3下运行它。