Python3找不到statsmodels.api,但我可以,我的皮棉也可以找到

问题描述 投票:0回答:1

我最近开始使用在WSL(Ubuntu 18.04 LTS)上运行的Python进行开发。

我遵循了here中的文档,并且能够运行简单的python脚本。

[我开始使用pip3numpy之类的pandas命令安装的库,它们运行正常。

当我尝试使用statsmodels软件包时出现问题。我已经使用pip3 install statsmodels

安装了它

我可以在/home/username/.local/lib/python3.6/site-packages/statsmodels中看到该程序包,甚至可以在该目录中看到api.py文件,但是,当我按照import statsmodels.api as sm的建议输入statsmodels website时,我得到:

error

控制台输出:

username@DESKTOP-1JP4BIE:/mnt/c/users/username/dev/project/playground$ python3 statsmodels.py 
Traceback (most recent call last):
  File "statsmodels.py", line 5, in <module>
    import statsmodels.api as sm
  File "/mnt/c/username/chris/dev/project/playground/statsmodels.py", line 5, in <module>
    import statsmodels.api as sm
ModuleNotFoundError: No module named 'statsmodels.api'; 'statsmodels' is not a package

我尝试卸载并重新安装(没有用)

我真的看不到任何能将此软件包与已安装的软件包区分开的东西。有人有见识吗?

pip python-3.6 statsmodels
1个回答
1
投票

感谢@Vorsprung durch Technik

问题是我的文件名为statsmodels.py。

命名我的python文件时,我会记住要格外小心。

© www.soinside.com 2019 - 2024. All rights reserved.