无法安装python 3.6.5

时间:2019-03-14 19:19:32

标签: python openssl python-3.6 wget

我正在尝试从源代码安装python 3.6.5,并将其链接到openssl。这是我的shell脚本:

# new openssl install
curl https://github.com/openssl/openssl/archive/OpenSSL_1_1_1a.zip | tar xz && cd OpenSSL_1_1_1a && ./config shared --prefix=/usr/local/ enable-weak-ssl-ciphers && make && make install

# Python install script
export LDFLAGS="-L/usr/local/lib/"
export LD_LIBRARY_PATH="/usr/local/lib/"
export CPPFLAGS="-I/usr/local/include -I/usr/local/include/openssl"
apt-get update
apt-get install build-essential checkinstall -y
apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev -y
cd /home/web/
wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz | tar xzf Python-3.6.5.tgz && cd Python-3.6.5 
./configure --prefix=/usr/local/ 
make install

当我尝试使用~/Downloads$ sudo bash custom_python.sh

从“下载”中运行它时

我得到:

tar: Child returned status 2
tar: Error is not recoverable: exiting now
Resolving www.python.org (www.python.org)... 151.101.16.223, 2a04:4e42:4::223
Connecting to www.python.org (www.python.org)|151.101.16.223|:443... connected.
ERROR: cannot verify www.python.org's certificate, issued by ‘CN=DigiCert SHA2 Extended Validation Server CA,OU=www.digicert.com,O=DigiCert Inc,C=US’:
  Unable to locally verify the issuer's authority.
To connect to www.python.org insecurely, use `--no-check-certificate'.
custom_python.sh: line 13: ./configure: No such file or directory
make: *** No rule to make target 'install'.  Stop.

是什么原因造成的?怎么解决呢? 我通常可以从浏览器中打开wget中提供的python url。

1 个答案:

答案 0 :(得分:0)

正如另一个用户所评论的那样,wget默认情况下不会将数据写入stdout。有两种方法可以修复脚本:

wget -O- https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz | tar xzf Python-3.6.5.tgz && cd Python-3.6.5

在这种情况下,您要将Wget输出到stdout。但是,我通常不喜欢这种方法。直接通过网络传送内容不是一个好主意。存在多个安全性和可靠性问题。

相反,您应该这样做:

wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz && tar xzf Python-3.6.5.tgz && cd Python-3.6.5

在理想情况下,您还要检查下载文件的签名/校验和,以确保档案没有损坏