ModuleNotFoundError: No module named 'pygam'

ModuleNotFoundError: No module named 'pygam'

我正在尝试执行 python 脚本,其中 pygamfrom pygam import LogisticGAM, LinearGAM ).

当我尝试执行此脚本时出现此错误: ModuleNotFoundError: 没有名为 'pygam' 的模块

pygam同时安装pippip3的问题。

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

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 重新安装它们时的结果:

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

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

pip install pygame

安装并重试。更多信息请访问 https://pypi.org/project/pygame/

确保您拥有正确版本的 python 和 pip。 尝试使用 运行 脚本使用的 python(正确的版本)再次安装它。 例如,您想要 运行 它与 [yhon3.5 使用以下命令:

python3.5 -m pip install pygam

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

也尝试使用 sudo 安装

sudo pip install pygam
# OR
sudo pip3 install pygam

pip -V 命令将为您提供当前 运行ning 版本的 pip 及​​其安装的 python 版本。 示例:

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 的多个版本,以上内容会派上用场。 如果有帮助,请告诉我们。