1 安装
1.1 安装依赖
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
yum install gcc gcc-c++ openssl-devel libffi-devel tk-devel
1.2 下载、解压
mkdir -p /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
xz -d Python-3.8.5.tar.xz
tar -xvf Python-3.8.5.tar
cd Python-3.8.5
1.3 安装
授权(谨慎操作)
sudo chmod -R 777 /usr/local/python3/Python-3.8.5
./configure --prefix=/usr/local/python3/Python-3.8.5_build
make && make install
# 如果您想要一个具有所有稳定优化活动(PGO 等)的发布版本,请运行
./configure --enable-optimizations
python3.8 解释器位置,一般是 /usr/local/bin/python3.8
删除原来的软连接
rm -rf /usr/bin/python3.8
rm -rf /usr/bin/pip3.8
添加python3与pip3的软链接
ln -s /usr/local/python3/Python-3.8.5_build/bin/python3.8 /usr/bin/python3.8
ln -s /usr/local/python3/Python-3.8.5_build/bin/pip3.8 /usr/bin/pip3.8
验证
python3.8 -V
pip3.8 -V
2 报错处理
WARNING: The directory ‘/home/ubuntu/.cache/pip’ or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag
sudo chown -R ubuntu/home/ubuntu/.cache/pip/
sudo chown -R ubuntu/home/ubuntu/.cache/pip/http/
sudo chown -R ubuntu /home/ubuntu/.cache/pip/
sudo chown -R ubuntu /home/ubuntu/.cache/pip/http
sudo find / -name 'lsb_release.py'
sudo cp /usr/share/pyshared/lsb_release.py /usr/local/soft/python3/lib/python3.7/
作者:有勇气的牛排
<h2><a id="1__0"></a>1 安装</h2>
<h3><a id="11__1"></a>1.1 安装依赖</h3>
<pre><code class="lang-powershell">yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
yum install gcc gcc-c++ openssl-devel libffi-devel tk-devel
</code></pre>
<h3><a id="12__9"></a>1.2 下载、解压</h3>
<pre><code class="lang-powershell">mkdir -p /usr/local/python3
cd /usr/local/python3
wget https://www.python.org/ftp/python/3.8.5/Python-3.8.5.tar.xz
xz -d Python-3.8.5.tar.xz
tar -xvf Python-3.8.5.tar
cd Python-3.8.5
</code></pre>
<h3><a id="13__18"></a>1.3 安装</h3>
<p>授权(谨慎操作)</p>
<pre><code class="lang-powershell">sudo chmod -R 777 /usr/local/python3/Python-3.8.5
</code></pre>
<pre><code class="lang-powershell">./configure --prefix=/usr/local/python3/Python-3.8.5_build
make && make install
# 如果您想要一个具有所有稳定优化活动(PGO 等)的发布版本,请运行
./configure --enable-optimizations
</code></pre>
<p>python3.8 解释器位置,一般是 <code>/usr/local/bin/python3.8</code></p>
<p>删除原来的软连接</p>
<pre><code class="lang-powershell">rm -rf /usr/bin/python3.8
rm -rf /usr/bin/pip3.8
</code></pre>
<p>添加python3与pip3的软链接</p>
<pre><code class="lang-powershell">ln -s /usr/local/python3/Python-3.8.5_build/bin/python3.8 /usr/bin/python3.8
ln -s /usr/local/python3/Python-3.8.5_build/bin/pip3.8 /usr/bin/pip3.8
</code></pre>
<p>验证</p>
<pre><code class="lang-powershell">python3.8 -V
pip3.8 -V
</code></pre>
<h3><a id="2__52"></a>2 报错处理</h3>
<p>WARNING: The directory ‘/home/ubuntu/.cache/pip’ or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo’s -H flag</p>
<pre><code class="lang-powershell">sudo chown -R ubuntu/home/ubuntu/.cache/pip/
sudo chown -R ubuntu/home/ubuntu/.cache/pip/http/
</code></pre>
<p>sudo chown -R ubuntu /home/ubuntu/.cache/pip/<br />
sudo chown -R ubuntu /home/ubuntu/.cache/pip/http</p>
<pre><code class="lang-powershell">sudo find / -name 'lsb_release.py'
sudo cp /usr/share/pyshared/lsb_release.py /usr/local/soft/python3/lib/python3.7/
</code></pre>
<p>作者:有勇气的牛排</p>
留言