哈喽,大家好,我是有勇气的牛排(全网同名)🐮🐮🐮
有问题的小伙伴欢迎在文末评论,点赞、收藏是对我最大的支持!!!。
文章目录
1 python安装
1.1 源码安装
linux源码安装
python3 setup.py install
tar -zxvf ***.tar.gz
python setup.py install
2 pip 换源
通常国内使用python的pip命令安装第三方的时候,会因为墙的原因,导致pip安装速度很慢,所以下面我们给出换国内源方法
-
命令统一在命令行下使用
-
参数 -i
: 使用换源地址安装
常用源
https://mirrors.aliyun.com/pypi/simple
https://pypi.douban.com/simple
https://pypi.mirrors.ustc.edu.cn/simple/
https://pypi.tuna.tsinghua.edu.cn/simple
2.1 不换源 一次性使用
pip后面跟python版本号,如果只安装一个python解释器,就可以不用写版本号
pip3.7 install bottle -i https://pypi.douban.com/simple
pip3.6 install requests -i https://pypi.douban.com/simple
pip install lxml -i https://pypi.douban.com/simple
pip install bs4 -i https://pypi.douban.com/simple
pip install tornado -i https://pypi.douban.com/simple
pip install twisted -i https://pypi.douban.com/simple
实战演练:安装tensorflow
pip install tensorflow -i https://mirrors.aliyun.com/pypi/simple
pip install tensorflow==1.15.0 -i https://mirrors.aliyun.com/pypi/simple
2.2 换源 永久修改
2.2.1 linux
vim ~/.pip/pip.conf (没有就创建一个)
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
2.2.2 windows
创建文件
C:\Users\Administrator\pip.ini
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
2.2.3 使用
永久修改后,我们命令安装时,就不用带版本号了,如安装matplotlib
pip install matplotlib
3 更新pip
python3.8 -m pip install --upgrade pip
<p><font face="楷体,华文行楷,隶书,黑体" color="red" size="4"><strong>哈喽,大家好,我是有勇气的牛排(全网同名)🐮🐮🐮</strong></font></p>
<p><font face="楷体,华文行楷,隶书,黑体" color="blue" size="4"><strong>有问题的小伙伴欢迎在文末评论,点赞、收藏是对我最大的支持!!!。</strong></font></p>
<p><h3>文章目录</h3><ul><ul><li><a href="#1_python_6">1 python安装</a></li><ul><li><a href="#11__8">1.1 源码安装</a></li></ul><li><a href="#2_pip__20">2 pip 换源</a></li><ul><li><a href="#21___41">2.1 不换源 一次性使用</a></li><li><a href="#22___68">2.2 换源 永久修改</a></li><ul><li><a href="#221_linux_70">2.2.1 linux</a></li><li><a href="#222_windows_81">2.2.2 windows</a></li><li><a href="#223__92">2.2.3 使用</a></li></ul></ul><li><a href="#3_pip_101">3 更新pip</a></li></ul></ul></p>
<h2><a id="1_python_6"></a>1 python安装</h2>
<h3><a id="11__8"></a>1.1 源码安装</h3>
<p>linux源码安装</p>
<pre><div class="hljs"><code class="lang-shell">python3 setup.py install
tar -zxvf ***.tar.gz
python setup.py install
</code></div></pre>
<h2><a id="2_pip__20"></a>2 pip 换源</h2>
<p>通常国内使用python的pip命令安装第三方的时候,会因为墙的原因,导致pip安装速度很慢,所以下面我们给出换国内源方法</p>
<ul>
<li>
<p>命令统一在命令行下使用</p>
</li>
<li>
<p><code>参数 -i</code>: 使用换源地址安装</p>
</li>
</ul>
<p><strong>常用源</strong></p>
<pre><div class="hljs"><code class="lang-python"><span class="hljs-comment"># 阿里</span>
https://mirrors.aliyun.com/pypi/simple
<span class="hljs-comment"># 豆瓣</span>
https://pypi.douban.com/simple
<span class="hljs-comment"># 中科大</span>
https://pypi.mirrors.ustc.edu.cn/simple/
<span class="hljs-comment"># 清华</span>
https://pypi.tuna.tsinghua.edu.cn/simple
</code></div></pre>
<h3><a id="21___41"></a>2.1 不换源 一次性使用</h3>
<p>pip后面跟python版本号,如果只安装一个python解释器,就可以不用写版本号</p>
<pre><div class="hljs"><code class="lang-python"><span class="hljs-comment"># 当电脑有多个解释器时pip带版本 具体要到安装目录指定后面的数字 然后这里使用</span>
pip3<span class="hljs-number">.7</span> install bottle -i https://pypi.douban.com/simple
pip3<span class="hljs-number">.6</span> install requests -i https://pypi.douban.com/simple
<span class="hljs-comment"># 如果为一个python解释器直接pip即可</span>
pip install lxml -i https://pypi.douban.com/simple
pip install bs4 -i https://pypi.douban.com/simple
pip install tornado -i https://pypi.douban.com/simple
pip install twisted -i https://pypi.douban.com/simple
</code></div></pre>
<p>实战演练:安装<code>tensorflow </code></p>
<pre><div class="hljs"><code class="lang-python"><span class="hljs-comment"># 安装最新</span>
pip install tensorflow -i https://mirrors.aliyun.com/pypi/simple
<span class="hljs-comment"># 安装指定版本</span>
pip install tensorflow==<span class="hljs-number">1.15</span><span class="hljs-number">.0</span> -i https://mirrors.aliyun.com/pypi/simple
</code></div></pre>
<h3><a id="22___68"></a>2.2 换源 永久修改</h3>
<h4><a id="221_linux_70"></a>2.2.1 linux</h4>
<pre><code class="lang-powershell">vim ~/.pip/pip.conf (没有就创建一个)
</code></pre>
<pre><code class="lang-powershell">[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
</code></pre>
<h4><a id="222_windows_81"></a>2.2.2 windows</h4>
<p>创建文件<br />
<code>C:\Users\Administrator\pip.ini</code></p>
<pre><div class="hljs"><code class="lang-ini"><span class="hljs-section">[global]</span>
<span class="hljs-attr">timeout</span> = <span class="hljs-number">6000</span>
<span class="hljs-attr">index-url</span> = http://pypi.douban.com/simple
<span class="hljs-attr">trusted-host</span> = pypi.douban.com
</code></div></pre>
<h4><a id="223__92"></a>2.2.3 使用</h4>
<p>永久修改后,我们命令安装时,就不用带版本号了,如安装<code>matplotlib</code></p>
<pre><div class="hljs"><code class="lang-python"><span class="hljs-comment"># 安装 matplotlib</span>
pip install matplotlib
</code></div></pre>
<h2><a id="3_pip_101"></a>3 更新pip</h2>
<pre><div class="hljs"><code class="lang-shell">python3.8 -m pip install --upgrade pip
</code></div></pre>
留言