python - 在带 wifi 的公寓中安装 python 包时出错

标签 python bash

在 Windows 10 中,我安装了 linux 子系统。

在 cmd 中,我运行 bash。

在庆典中,

  • 我发现我目前的 Python 是 2.7.6。
  • 我想安装 regex python 库。但是下面有错误,请问有大佬知道怎么解决吗?

谢谢。

$ sudo  python get-pip.py
sudo: unable to resolve host TINGL-ND1
The directory '/home/t/.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/t/.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.
/tmp/tmp6uv5w8/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HTTPS request has \
been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the\
 server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer versio\
n of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingw\
arning.
/tmp/tmp6uv5w8/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLConte\
xt object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connecti\
ons to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.read\
thedocs.io/en/latest/security.html#insecureplatformwarning.
Requirement already up-to-date: pip in /usr/local/lib/python2.7/dist-packages



$ sudo -H pip  install  regex
sudo: unable to resolve host Ocean1
Collecting regex
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:318: SNIMissingWarning: An HT\
TPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. Th\
is may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade t\
o a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.\
html#snimissingwarning.
  SNIMissingWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning:\
 A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause cert\
ain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see http\
s://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Using cached regex-2017.01.17.tar.gz
Building wheels for collected packages: regex
  Running setup.py bdist_wheel for regex ... ^[[?25lerror
  Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qc8Myq/regex\
/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code,\
 __file__, 'exec'))" bdist_wheel -d /tmp/tmpIm5vbcpip-wheel- --python-tag cp27:
  /usr/local/lib/python2.7/dist-packages/setuptools/dist.py:333: UserWarning: Normalizing '2017.01.17' to '2017.1.17'
    normalized_version,
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-x86_64-2.7
  copying Python2/regex.py -> build/lib.linux-x86_64-2.7
  copying Python2/_regex_core.py -> build/lib.linux-x86_64-2.7
  copying Python2/test_regex.py -> build/lib.linux-x86_64-2.7
  running build_ext
  building '_regex' extension
  creating build/temp.linux-x86_64-2.7
  creating build/temp.linux-x86_64-2.7/Python2
  x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/inc\
lude/python2.7 -c Python2/_regex.c -o build/temp.linux-x86_64-2.7/Python2/_regex.o
  Python2/_regex.c:46:20: fatal error: Python.h: No such file or directory
   #include "Python.h"
                      ^
  compilation terminated.
  error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  Failed building wheel for regex
^[[?25h  Running setup.py clean for regex
Failed to build regex
Installing collected packages: regex
  Running setup.py install for regex ... ^[[?25lerror
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-qc8Myq/reg\
ex/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(cod\
e, __file__, 'exec'))" install --record /tmp/pip-oM77xP-record/install-record.txt --single-version-externally-managed -\
-compile:
    /usr/local/lib/python2.7/dist-packages/setuptools/dist.py:333: UserWarning: Normalizing '2017.01.17' to '2017.1.17'
      normalized_version,
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying Python2/regex.py -> build/lib.linux-x86_64-2.7
    copying Python2/_regex_core.py -> build/lib.linux-x86_64-2.7
    copying Python2/test_regex.py -> build/lib.linux-x86_64-2.7
    running build_ext
    building '_regex' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/Python2
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/i\
nclude/python2.7 -c Python2/_regex.c -o build/temp.linux-x86_64-2.7/Python2/_regex.o
    Python2/_regex.c:46:20: fatal error: Python.h: No such file or directory

最佳答案

此错误消息表明您缺少 Python 开发库。

Python2/_regex.c:46:20: fatal error: Python.h: No such file or directory

您可以使用以下命令安装它们。

适用于 Linux/Debian/Ubuntu 的 Windows 子系统

sudo apt-get install python-dev

Fedora/RedHat/CentOS

sudo yum install python-devel

关于python - 在带 wifi 的公寓中安装 python 包时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41816115/

相关文章:

Python 去聚合

python (pyodbc):Run ms access query from python results to size error

bash 用户输入如果

python - iotop 脚本无法通过自定义脚本执行工作

python - 乌鸦不向 Sentry 报告异常

python - 如何统计提交的 GET 参数的数量?

python - 从任意概率密度函数生成随机数

linux - 在 bash (Linux) 中从一个 csv 中查找另一个 csv 中的值(如 vlookup)

linux - 验证文件是否已创建 shell

linux - 在 bash 的每个子目录中创建所有文件的列表