web-dev-qa-db-ja.com

ウィンドウubuntu bashにpython3.6をインストールする方法

Window 10 build 15002でubuntu 16.04 window bashを使用します。window10 bashでpython3.6を使用します。その後、python3.6 tar ballをインストールしました。

インストール中にREADMEファイルの後に設定し、

$ ./configure; make; make test; Sudo make install;

ただし、インストール中にエラーが発生しました。以下は「./confiugure」についてです

➜  Python-3.6.0 ./configure
checking build system type... x86_64-unknown-linux-gnu
checking Host system type... x86_64-unknown-linux-gnu
checking for python3.6... python3.6
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/usr/local/develop/language/Python-3.6.0':
configure: error: C compiler cannot create executables
See `config.log' for more details

これは以下のconfig.logです

This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by python configure 3.6, which was
generated by GNU Autoconf 2.69.  Invocation command line was

$ ./configure
## --------- ##
## Platform. ##
## --------- ##

hostname = DESKTOP-44GISIR
uname -m = x86_64
uname -r = 4.4.0-43-Microsoft
uname -s = Linux
uname -v = #1-Microsoft Wed Dec 31 14:42:53 PST 2014

/usr/bin/uname -p = unknown
/bin/uname -X     = unknown

/bin/Arch              = unknown
/usr/bin/Arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /usr/local/sbin
PATH: /usr/local/bin
PATH: /usr/sbin
PATH: /usr/bin
PATH: /sbin
PATH: /bin
PATH: /usr/games
PATH: /usr/local/games
PATH: /mnt/c/ProgramData/Oracle/Java/javapath_target_3702546
PATH: /mnt/c/Windows/System32
PATH: /mnt/c/Windows
PATH: /mnt/c/Windows/System32/wbem
PATH: /mnt/c/Windows/System32/WindowsPowerShell/v1.0
PATH: /mnt/c/Program Files/nodejs
PATH: /mnt/c/Program Files/Git/cmd
PATH: /mnt/c/Program Files/Intel/WiFi/bin
PATH: /mnt/c/Program Files/Common Files/Intel/WirelessCommon
PATH: /mnt/c/Users/dydwl/AppData/Local/Microsoft/WindowsApps
PATH: /mnt/c/Program Files/Bandizip/7z
PATH: /mnt/c/Users/dydwl/AppData/Roaming/npm
PATH: /mnt/c/Users/dydwl/AppData/Local/atom/bin
PATH: /mnt/c/Program Files/Intel/WiFi/bin
PATH: /mnt/c/Program Files/Common Files/Intel/WirelessCommon


## ----------- ##
## Core tests. ##
## ----------- ##

configure:2792: checking build system type
configure:2806: result: x86_64-unknown-linux-gnu
configure:2826: checking Host system type
configure:2839: result: x86_64-unknown-linux-gnu
configure:2869: checking for python3.6
configure:2885: found /usr/bin/python3.6
configure:2896: result: python3.6
configure:3005: checking for --enable-universalsdk
configure:3052: result: no
configure:3075: checking for --with-universal-archs
configure:3090: result: no
configure:3240: checking MACHDEP
configure:3446: result: linux
configure:3467: checking for --without-gcc
configure:3490: result: no
configure:3493: checking for --with-icc
configure:3513: result: no
configure:3637: checking for gcc
configure:3653: found /usr/bin/gcc
configure:3664: result: gcc
configure:3893: checking for C compiler version
configure:3902: gcc --version >&5
gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4
Copyright (C) 2013 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3913: $? = 0
configure:3902: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.8/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.8.4-2ubuntu1~14.04.3' --with-bugurl=file:///usr/share/doc/gcc-4.8/README.Bugs --enable-languages=c,c++,Java,go,d,fortran,
objc,obj-c++ --prefix=/usr --program-suffix=-4.8 --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/
usr/include/c++/4.8 --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-libmudf
lap --enable-plugin --with-system-zlib --disable-browser-plugin --enable-Java-awt=gtk --enable-gtk-cairo --with-Java-home=/usr/lib/jvm/Java-1.5.0-gcj-4.8-AMD64/jre --enable-Java-home --w
ith-jvm-root-dir=/usr/lib/jvm/Java-1.5.0-gcj-4.8-AMD64 --with-jvm-jar-dir=/usr/lib/jvm-exports/Java-1.5.0-gcj-4.8-AMD64 --with-Arch-directory=AMD64 --with-ecj-jar=/usr/share/Java/Eclipse
-ecj.jar --enable-objc-gc --enable-multiarch --disable-werror --with-Arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --with-tune=generic --enable-checking=release --build=x
86_64-linux-gnu --Host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.8.4 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
configure:3913: $? = 0
configure:3902: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3913: $? = 4
configure:3902: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'
gcc: fatal error: no input files
compilation terminated.
configure:3913: $? = 4
configure:3933: checking whether the C compiler works
configure:3955: gcc    conftest.c  >&5
/usr/bin/ld: cannot find crt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
/usr/bin/ld: cannot find -lc
/usr/bin/ld: cannot find crtn.o: No such file or directory
collect2: error: ld returned 1 exit status
configure:3959: $? = 1
configure:3997: result: no
configure: failed program was:
| /* confdefs.h */
| #define _GNU_SOURCE 1
| #define _NETBSD_SOURCE 1
| #define __BSD_VISIBLE 1
| #define _BSD_TYPES 1
| #define _DARWIN_C_SOURCE 1
| #define _XOPEN_SOURCE 700
| #define _XOPEN_SOURCE_EXTENDED 1
| #define _POSIX_C_SOURCE 200809L
| /* end confdefs.h.  */
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:4002: error: in `/usr/local/develop/language/Python-3.6.0':
configure:4004: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-unknown-linux-gnu
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=
ac_cv_env_CPPFLAGS_value=
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=
ac_cv_env_LDFLAGS_value=
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_MACHDEP_set=
ac_cv_env_MACHDEP_value=
ac_cv_env_PKG_CONFIG_LIBDIR_set=
ac_cv_env_PKG_CONFIG_LIBDIR_value=
ac_cv_env_PKG_CONFIG_PATH_set=
ac_cv_env_PKG_CONFIG_PATH_value=
ac_cv_env_PKG_CONFIG_set=
ac_cv_env_PKG_CONFIG_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_Host_alias_set=
ac_cv_env_Host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_Host=x86_64-unknown-linux-gnu
ac_cv_prog_PYTHON_FOR_GEN=python3.6
ac_cv_prog_ac_ct_CC=gcc

## ----------------- ##
## Output variables. ##
## ----------------- ##
ABIFLAGS=''
AR=''
Arch_RUN_32BIT=''
ARFLAGS=''
BASECFLAGS=''
BASECPPFLAGS=''
BLDLIBRARY=''
BLDSHARED=''
BUILDEXEEXT=''
CC='gcc'
CCSHARED=''
CFLAGS=''
CFLAGSFORSHARED=''
CFLAGS_NODIST=''
CONFIGURE_MACOSX_DEPLOYMENT_TARGET=''
CONFIG_ARGS=''
CPP=''
CPPFLAGS=''
CXX=''
DEFS=''
DEF_MAKE_ALL_RULE=''
DEF_MAKE_RULE=''
DFLAGS=''
DLINCLDIR=''
DLLLIBRARY=''
DTRACE=''
DTRACE_HEADERS=''
DTRACE_OBJS=''
DYNLOADFILE=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
ENSUREPIP=''
EXEEXT=''
EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
EXT_SUFFIX=''
FRAMEWORKALTINSTALLFIRST=''
FRAMEWORKALTINSTALLLAST=''

(................... )

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1
#define _XOPEN_SOURCE 700
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200809L
configure: exit 77

私はそれが有線であると思う、私はgccを使用して単純なcソースをコンパイルするテストします。

// test.c
#include <stdio.h>
int main()
{
   printf("This works\n");
   return 0;
}


$ gcc -o test test.c

それが結果です

➜  Python-3.6.0 gcc -o test test.c
test.c:1:19: fatal error: stdio.h: No such file or directory
#include <stdio.h> 
                 ^          
compilation terminated.

私のgccが 'stdio.h'に関する基本的なヘッダーを読み取れないのはなぜですか?また、ウィンドウ10のbashでインストールの問題を解決するには...

14
drakejin

上記の答えは完全に正しいですが、pipも必要な場合(Pythonをpipなしで使用するのが難しいと思います)、仮想環境内からpipをインストールする必要があります(venv )。最初のインストールPython 3.6前述のように...

Sudo add-apt-repository ppa:jonathonf/python-3.6
Sudo apt update
Sudo apt install python3.6

それぞれのPython 3.6プロジェクトで(プロジェクトディレクトリ内から)venvを作成し、そのようにpipをインストールします...

python3.6 -m venv env --without-pip
source env/bin/activate
curl https://bootstrap.pypa.io/get-pip.py | python3
11
Simon
  1. Sudo add-apt-repository ppa:jonathonf/python-3.6
  2. Sudo apt-get update
  3. Sudo apt-get install python3.6
20
Ahsan Naseem