我正在尝试让Pymses在我的计算机上工作以取得学士学位论文。我首先按照网站上描述的方式安装Anaconda,然后将以下内容添加到我的.bashrc文件中:
export PATH="/users/<name>/anaconda3/bin:$PATH"
此外,由于推荐给Pymses使用wxPython模块,因此我添加了它。然后,我按照Pymses文档的说明通过在Pymses文件夹中使用“ make”命令来安装它,并将以下两行添加到我的.bashrc文件中。
export PYTHONPATH=$PYTHONPATH:/users/<name>/pymses
export PATH=$PATH:~/pymses/bin
现在,当我通过控制台打开Python并输入“ import pymses”时,出现以下错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/users/<name>/pymses/pymses/__init__.py", line 21, in <module>
from sources.ramses.output import RamsesOutput
ModuleNotFoundError: No module named 'sources'
当我在Pymses文件夹中输入“ make test”时,也会发生同样的情况:
nosetests -v -w pymses
Failure: ModuleNotFoundError (No module named 'sources') ... ERROR
======================================================================
ERROR: Failure: ModuleNotFoundError (No module named 'sources')
----------------------------------------------------------------------
Traceback (most recent call last):
File "/users/<name>/anaconda3/lib/python3.6/site-packages/nose/failure.py", line 39, in runTest
raise self.exc_val.with_traceback(self.tb)
File "/users/<name>/anaconda3/lib/python3.6/site-packages/nose/loader.py", line 417, in loadTestsFromName
addr.filename, addr.module)
File "/users/<name>/anaconda3/lib/python3.6/site-packages/nose/importer.py", line 47, in importFromPath
return self.importFromDir(dir_path, fqname)
File "/users/<name>/anaconda3/lib/python3.6/site-packages/nose/importer.py", line 94, in importFromDir
mod = load_module(part_fqname, fh, filename, desc)
File "/users/<name>/anaconda3/lib/python3.6/imp.py", line 245, in load_module
return load_package(name, filename)
File "/users/<name>/anaconda3/lib/python3.6/imp.py", line 217, in load_package
return _load(spec)
File "<frozen importlib._bootstrap>", line 684, in _load
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/users/<name>/pymses/pymses/__init__.py", line 21, in <module>
from sources.ramses.output import RamsesOutput
ModuleNotFoundError: No module named 'sources'
----------------------------------------------------------------------
Ran 1 test in 0.003s
FAILED (errors=1)
Makefile:21: recipe for target 'test' failed
make: *** [test] Error 1
部分问题是我已经很长时间没有使用Python了,所以我真的不知道从哪里开始,请记住这一点。我查找了文件'pymses / pymses / init .py'(在init之前和之后都有两个下划线,而不是init为粗体),并找到以下代码:
from sources.ramses.output import RamsesOutput
import sources
import filters
'Sources'是与该文件位于同一目录/文件夹中的文件夹,'ramses'是'sources'中的文件夹,而'output.py'是'ramses'中的python文件。
我对问题所在一无所知。有什么想法吗?
e:在“源”目录中,还有另一个包含以下代码的初始化文件:
r"""
:mod:`pymses.sources` --- Source file formats package
=====================================================
"""
import ramses
import hop
__all__ = ["ramses", "hop"]
e2:为完成操作,ramses目录中还有一个init文件,其中包含以下代码:
r"""
:mod:`pymses.sources.ramses` --- RAMSES file formats package
************************************************************
"""
from output import *
from octree import CameraOctreeDatasource, CameraOctreeDataset
import hilbert
import tree_utils
import filename_utils
__all__ = ["hilbert", "tree_utils", "filename_utils", "CameraOctreeDatasource", "CameraOctreeDataset"]
__all__.extend(output.__all__)
为清楚起见,其结构如下(目录以'表示):
答案 0 :(得分:0)
只需打开一个终端并执行
pip install sources
答案 1 :(得分:0)
尝试在源文件夹中添加 __ init __。py 文件。
转到源目录,执行$ touch __init__.py
命令。