2017-01-23 26 views
0

Windows 10では、Linuxサブシステムをインストールしました。wifiのアパートにpythonパッケージをインストールする際にエラーが発生しました

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.hが含まpython-devパッケージをインストールする必要があります。

Linuxサブシステムを使用せずに、Python for Windowsをインストールするほうがはるかに簡単な解決策があります。 Python 3.5から始めてpip(実際にはかなり頻繁に)プリコンパイルされたバイナリバージョンがインストールされるため、多くの問題を解決できます。

実際、Python 3.5以降、ほとんどのパッケージをLinuxにインストールするよりも、Windowsにインストールする方が簡単です。

+1

'' python3'で 'virtualenv'を使う場合は' sudo apt-get install python3-dev'を使ってヘッダを取得してください – Eponymous

0

再(正規表現パッケージ)は、通常のPythonのインストールが付属しています

re

+0

私のプログラムは 'regex'と' re'の両方を必要とします – Tim

1

このエラーメッセージは、Pythonの開発ライブラリが欠落していることを示しています。

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

次のコマンドを使用してインストールできます。

Linux用のWindowsサブシステム/ Debianの/ Ubuntuの

sudo apt-get install python-dev 

のFedora/RedHatの/ CentOSの

sudo yum install python-devel 
関連する問題