pip - Python3 找不到 statsmodels.api 但我可以,我的 linter 也可以
问题描述
我最近开始使用在 WSL(Ubuntu 18.04 LTS)上运行的 Python 进行开发。
我按照此处的文档进行操作,并且能够运行简单的 python 脚本。
我开始玩弄我使用pip3
命令安装的库,例如numpy
andpandas
这些工作正常。
当我尝试使用该statsmodels
软件包时会出现问题。我已经安装了它pip3 install statsmodels
我可以看到包,/home/username/.local/lib/python3.6/site-packages/statsmodels
我什至可以看到该api.py
目录中的文件,但是,当我按照statsmodels 网站import statsmodels.api as sm
上的建议键入时,我得到:
控制台输出:
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
我试过卸载并重新安装(没有用)
我真的看不出有什么可以将这个软件包与我安装的其他软件包区分开来。有没有人有任何见解?
解决方案
谢谢@Vorsprung durch Technik
问题是我的文件名是 statsmodels.py。
我会记得在命名我的 python 文件时要更加小心。
推荐阅读
- angular-material - 是否有可用于材料角度的辅助 css 的文档?
- encoding - 不正确的编码,php 单元,symfony
- r - Spatstat - 如何比较两个温度空间域?
- r - 用同一列中以前的非空白单元格填充空白单元格
- oracle - Oracle Forms 获取值和列(作为要发送的参数)我在 F11 和 Ctrl + F11 之间写入值以过滤表格列表
- c++ - 禁用优化后,quick-bench.com 上的基准测试速度更快
- ruby-on-rails - 无法上传文件/图像导轨舒适的墨西哥沙发 cms
- c++ - 对 __cxa_throw_bad_array_new_length 的未定义引用(g++ 7.4)
- reactjs - Typescript (react)t:推断对象值中的泛型
- maven - POST 和 PUT 的状态代码通过 pom.xml mvn 测试失败