2017-01-23 61 views
0

在Windows 10中,我安裝了linux子系統。安裝python軟件包在wifi公寓的錯誤

在cmd中,我運行bash。

在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 
+0

你是什麼意思? – Tim

回答

2

您需要安裝python-dev包,其中包括Python.h。

雖然有一個更簡單的解決方案 - 在沒有使用Linux子系統的情況下爲Windows安裝Python。有時(實際上,經常)會從Python 3.5 pip開始安裝預編譯的二進制版本,爲您節省很多麻煩。

事實上,自從Python 3.5以來,在Windows上安裝大部分軟件包比在Linux上安裝更容易。

+1

如果在'python3'中使用'virtualenv',一定要'sudo apt-get install python3-dev'來得到它的頭文件 – Eponymous

0

RE(正則表達式包),配備了常規的Python安裝

re

+0

我的程序需要'regex'和're' – Tim

1

此錯誤消息表明你缺少Python開發庫。

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

您可以使用以下命令安裝它們。

的Windows子系統用於Linux /於Debian/Ubuntu

sudo apt-get install python-dev 

的Fedora /紅帽/ CentOS的

sudo yum install python-devel