<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[【ubuntu16.04转换python3.5到python3.6】]]></title><description><![CDATA[<p>现在换系统来不及了，等买了新电脑再说吧。最近跑detectron2发现没有python3.6还真的不行，由于我的pytorch以及其他的一些环境都是源码编译的，高度依赖于版本，因此简单的虚拟环境搞起来更加麻烦，不如全部换成python3.6吧。</p>
<ol>
<li>先安装python3.6</li>
</ol>
<pre><code>sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
</code></pre>
<ol start="2">
<li>切换python3.6为默认的python3</li>
</ol>
<pre><code>sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
</code></pre>
<p>此时，你再输入python3看一下：</p>
<pre><code>$ python3
Python 3.6.8 (default, Oct  9 2019, 14:04:01) 
[GCC 5.4.0 20160609] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; 

</code></pre>
<ol start="3">
<li>将你的pip修复一下</li>
</ol>
<pre><code>sudo apt purge python3-pip
sudo apt install python3-pip
</code></pre>
<ol start="4">
<li>修复 <code>Python.h: No such file or directory</code></li>
</ol>
<p>有时候你安装包会出现 <code>Python.h</code> 找不到，比如 <code>thefuck</code> 原因是没有安装dev</p>
<pre><code>/usr/include/python2.7/Python.h
/usr/include/python3.5m/Python.h
</code></pre>
<p>你会发现没有 <code>python3.6</code>, 那么问题就会变得很诡异了，此时你再安装一下numpy试试。</p>
<pre><code>sudo apt install python3.6-dev
</code></pre>
<p>可以解决这个问题.</p>
<ol start="5">
<li>Fix apt error</li>
</ol>
<pre><code> /usr/lib/python3/dist-packages# sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so

</code></pre>
<p>OK, 上面配置之后ubuntu16.04将可以永久使用python3.6作为默认。</p>
]]></description><link>http://t.manaai.cn/topic/211/ubuntu16-04转换python3-5到python3-6</link><generator>RSS for Node</generator><lastBuildDate>Mon, 08 Jun 2026 22:54:38 GMT</lastBuildDate><atom:link href="http://t.manaai.cn/topic/211.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 12 Oct 2019 06:48:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to 【ubuntu16.04转换python3.5到python3.6】 on Sat, 12 Oct 2019 08:51:37 GMT]]></title><description><![CDATA[<p>现在换系统来不及了，等买了新电脑再说吧。最近跑detectron2发现没有python3.6还真的不行，由于我的pytorch以及其他的一些环境都是源码编译的，高度依赖于版本，因此简单的虚拟环境搞起来更加麻烦，不如全部换成python3.6吧。</p>
<ol>
<li>先安装python3.6</li>
</ol>
<pre><code>sudo add-apt-repository ppa:jonathonf/python-3.6
sudo apt-get update
sudo apt-get install python3.6
</code></pre>
<ol start="2">
<li>切换python3.6为默认的python3</li>
</ol>
<pre><code>sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.6 2
</code></pre>
<p>此时，你再输入python3看一下：</p>
<pre><code>$ python3
Python 3.6.8 (default, Oct  9 2019, 14:04:01) 
[GCC 5.4.0 20160609] on linux
Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information.
&gt;&gt;&gt; 

</code></pre>
<ol start="3">
<li>将你的pip修复一下</li>
</ol>
<pre><code>sudo apt purge python3-pip
sudo apt install python3-pip
</code></pre>
<ol start="4">
<li>修复 <code>Python.h: No such file or directory</code></li>
</ol>
<p>有时候你安装包会出现 <code>Python.h</code> 找不到，比如 <code>thefuck</code> 原因是没有安装dev</p>
<pre><code>/usr/include/python2.7/Python.h
/usr/include/python3.5m/Python.h
</code></pre>
<p>你会发现没有 <code>python3.6</code>, 那么问题就会变得很诡异了，此时你再安装一下numpy试试。</p>
<pre><code>sudo apt install python3.6-dev
</code></pre>
<p>可以解决这个问题.</p>
<ol start="5">
<li>Fix apt error</li>
</ol>
<pre><code> /usr/lib/python3/dist-packages# sudo cp apt_pkg.cpython-35m-x86_64-linux-gnu.so apt_pkg.so

</code></pre>
<p>OK, 上面配置之后ubuntu16.04将可以永久使用python3.6作为默认。</p>
]]></description><link>http://t.manaai.cn/post/485</link><guid isPermaLink="true">http://t.manaai.cn/post/485</guid><dc:creator><![CDATA[刘看山]]></dc:creator><pubDate>Sat, 12 Oct 2019 08:51:37 GMT</pubDate></item></channel></rss>