Python 未导入 GETCH

Python not importing GETCH

我已经安装了(通过 PIP/The 终端)GETCH,但是 python 在我告诉它时无法识别它

import getch

我在 Mac

sudo pip install https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50
The directory '/Users/aaronoliver/Library/Caches/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 '/Users/aaronoliver/Library/Caches/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.
Collecting https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50
Downloading getch-1.0-python2.tar.gz
Requirement already satisfied (use --upgrade to upgrade): getch==1.0 from https://pypi.python.org/packages/source/g/getch/getch-1.0-python2.tar.gz#md5=586ea0f1f16aa094ff6a30736ba03c50 in /Library/Python/2.7/site-packages

您标记了这个问题 3.x,但您安装 getch 的证据清楚地表明它已安装在 2.7 的 site-packages 中。您还提供了 pip 到 Python 2 tarball 的显式路径。

为 Python 的一个版本安装软件包不会为其他版本安装它。 运行 pip3 为 Python 3 安装软件包(它可能被命名为 pip-3.5 或类似名称,具体取决于设置)。如果 pip3 没有安装,python3 -mensurepip 应该添加它(取决于 Python 次要版本),否则您必须手动安装它。无论哪种方式,一旦您拥有 pip3,您只需要正确安装软件包:

sudo pip3 install getch