首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >ModuleNotFoundError:没有名为“pygam”的模块

ModuleNotFoundError:没有名为“pygam”的模块
EN

Stack Overflow用户
提问于 2019-10-08 12:24:42
回答 2查看 1.5K关注 0票数 2

我正在尝试执行一个 pygam (从pygam导入LogisticGAM的,LinearGAM )的python脚本。

当我试图执行这个脚本时,我有一个错误:ModuleNotFoundError: No模块,名为'pygam'

pygampippip3一起安装的问题。

这是我尝试使用pip重新安装它时的结果。

代码语言:javascript
复制
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
WARNING: The directory '/home/mobelite/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: The directory '/home/mobelite/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied: pygam in /usr/local/lib/python2.7/dist-packages (0.8.0)
Requirement already satisfied: scipy in /usr/local/lib/python2.7/dist-packages (from pygam) (1.2.2)
Requirement already satisfied: future in /usr/local/lib/python2.7/dist-packages (from pygam) (0.17.1)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from pygam) (1.16.5)
Requirement already satisfied: progressbar2 in /usr/local/lib/python2.7/dist-packages (from pygam) (3.47.0)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from progressbar2->pygam) (1.12.0)
Requirement already satisfied: python-utils>=2.3.0 in /usr/local/lib/python2.7/dist-packages (from progressbar2->pygam) (2.3.0)

这就是当我尝试使用pip3重新安装它们时的结果:

代码语言:javascript
复制
The directory '/home/mobelite/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/mobelite/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): pygam in /usr/local/lib/python3.5/dist-packages
Requirement already satisfied (use --upgrade to upgrade): future in /usr/local/lib/python3.5/dist-packages (from pygam)
Requirement already satisfied (use --upgrade to upgrade): progressbar2 in /usr/local/lib/python3.5/dist-packages (from pygam)
Requirement already satisfied (use --upgrade to upgrade): numpy in ./.local/lib/python3.5/site-packages (from pygam)
Requirement already satisfied (use --upgrade to upgrade): scipy in ./.local/lib/python3.5/site-packages (from pygam)
Requirement already satisfied (use --upgrade to upgrade): python-utils>=2.3.0 in /usr/local/lib/python3.5/dist-packages (from progressbar2->pygam)
Requirement already satisfied (use --upgrade to upgrade): six in ./.local/lib/python3.5/site-packages (from progressbar2->pygam)
You are using pip version 8.1.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

我发现这很正常,因为我只是安装了它,但我不明白为什么他们看不到pygam

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-10-08 12:33:32

确保您没有使用虚拟环境,您必须安装游戏,只需运行以下命令:

代码语言:javascript
复制
pip install pygame

安装后再试一次。更多信息访问https://pypi.org/project/pygame/

票数 -3
EN

Stack Overflow用户

发布于 2019-10-08 12:34:41

确保您有正确版本的python和pip。尝试使用python重新安装它(使用正确的版本)来运行脚本。例如,您希望使用[yhon3.5 ]运行它,请使用以下命令:

代码语言:javascript
复制
python3.5 -m pip install pygam

我假设python3.5在上面的命令中调用Python 3.5,在我的系统上有python3调用Python 3.5

也可以尝试使用sudo进行安装

代码语言:javascript
复制
sudo pip install pygam
# OR
sudo pip3 install pygam

pip -V命令将提供当前正在运行的pip版本和安装在其中的python版本。示例:

代码语言:javascript
复制
pip -V
 pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)

pip3 -V
 pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)

如果在一个系统上安装了多个版本的python,那么上面的内容就很方便了。如果有帮助请告诉我们。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58286319

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档