Python 2.7 Python-pip-can';尽管安装了pythondev,但似乎找不到Python.h
我目前正在尝试安装getch,这是一个简单的python包,但遇到了不少困难。我最近以一种混乱的方式安装了pypy(我想让pypy工作,这是一个相当痛苦的过程),因此这可能与我遇到的问题有关 好吧,我试着跑Python 2.7 Python-pip-can';尽管安装了pythondev,但似乎找不到Python.h,python-2.7,pip,Python 2.7,Pip,我目前正在尝试安装getch,这是一个简单的python包,但遇到了不少困难。我最近以一种混乱的方式安装了pypy(我想让pypy工作,这是一个相当痛苦的过程),因此这可能与我遇到的问题有关 好吧,我试着跑 sudo pip install getch 我得到了错误 error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 另外,还有一个字符编码错误 这是人们在没有安装pythondev时遇到的错误。然而,我知道。我试图通
sudo pip install getch
我得到了错误
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
另外,还有一个字符编码错误
这是人们在没有安装pythondev时遇到的错误。然而,我知道。我试图通过下载包并手动安装来解决这个问题
sudo python setup.py install
也给了我上面的gcc错误。我已经安装了gcc,x86_64-linux-gnu-gcc可以在终端上正常工作。我用c编写了一个简单的hello world程序,其中只包含Python.h。这也很好。在删除——从我的系统中清除pypy、python和python-dev之后,我只重新安装了python和python-dev,仍然存在同样愚蠢的问题
有人有什么想法吗
这是我得到的准确错误的粘贴箱。pastebin.com/mjRdADZx您需要手动下载Python 2版本并安装它。pip下载的版本是针对Python3的 线索是这样的:
Downloading/unpacking getch
Downloading getch-1.0.tar.gz # This is the Python 3 package
Running setup.py egg_info for package getch
Installing collected packages: getch
Running setup.py install for getch
building 'getch' extension
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/local/include -I/usr/include -I/usr/include/python2.7 -c getchmodule.c -o build/temp.linux-i686-2.7/getchmodule.o
getchmodule.c: In function ‘getch_getche’:
getchmodule.c:36:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: In function ‘getch_getch’:
getchmodule.c:43:6: warning: unused variable ‘ok’ [-Wunused-variable]
getchmodule.c: At top level:
getchmodule.c:54:15: error: variable ‘getchmodule’ has initializer but incomplete type
getchmodule.c:55:4: error: ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function)
python2版本也是1.0,但文件名是getch-1.0-python2.tar.gz
。你可以下载它
下载后,提取归档文件,然后从提取的目录中安装
python setup.py
。显示实际错误(来自gcc)。至少,用Python.h显示您的问题所在的行,并包含pastebin中的信息。日志表明(我不确定)您正在尝试将Python3扩展编译为Python2扩展。手动下载tarball并尝试安装:pip安装getch-1.0-python2.tar.gz
。无关:使用virtualenv包含您的实验——如果您破坏了系统python安装;这可能会使系统无法使用。有没有办法将此需求嵌入requirements.txt文件中,以便在安装时将其愉快地安装到virtualenv中?这是PyPi库中可以修复的问题吗?我很惊讶pip会为错误版本的Python删除一个库。