ImportError: No module named 'pystan'on MacOS

ImportError: No module named 'pystan'on MacOS

我使用 pip install pystan 在 python 虚拟环境中安装了 pystan。我检查了模块是否列出了 pip freeze。但是当我 运行 带有 import pystan 的代码时。它给出了找不到模块的错误。

下面是 pip freeze 命令的输出。它显示 pystan 版本 3.3.0

aiohttp==3.7.4.post0
appdirs==1.4.4
async-timeout==3.0.1
attrs==21.2.0
chardet==4.0.0
clikit==0.6.2
crashtest==0.3.1
httpstan==4.6.0
idna==3.2
lz4==3.1.3
marshmallow==3.13.0
multidict==5.2.0
numpy==1.21.2
pandas==1.3.3
pastel==0.2.1
pylev==1.4.0
pysimdjson==3.2.0
pystan==3.3.0
python-dateutil==2.8.2
pytz==2021.3
six==1.16.0
typing-extensions==3.10.0.2
webargs==8.0.1
yarl==1.7.0

然而,当我尝试从控制台导入模块时,它抛出以下错误。

import pystan
Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "/Applications/PyCharm CE.app/Contents/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'pystan'

导入列出的任何其他模块不会引发错误。

我在这里找到了解决方案 link

Apparently the most recent versions of pystan (>= 3) use stan instead of pystan in the import statement, whereas in earlier versions it was just pystan.

如果安装 pystan (>=3) 使用 import stan 而不是 import pystan