• 拿到一个新的Ubuntu,你应该这样设置Python环境


    一、为了快点更新,首先替换apt源(感谢https://blog.csdn.net/zhangjiahao14/article/details/80554616)

      1.复制源文件备份,以防万一

      我们要修改的文件是sources.list,它在目录/etc/apt/下,sources.list是包管理工具apt所用的记录软件包仓库位置的配置文件,同样类型的还有位于 同目录下sources.list.d文件下的各种.list后缀的各文件。

      命令如下:

      sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak

      2.编辑源列表文件

      命令如下:

      sudo vim /etc/apt/sources.list

      如果报错:sudo:vim:command not found 说明没装vim编辑器

      使用命令:

      sudo apt-get install vim 安装即可

      

      3.查看新版本信息

      其实Ubuntu18.04版之前的任一版更改apt源为国内源方法早就有了,内容大同小异,我们应当掌握其规律了,其实每一版内容不同的地方就是版本号(或者官方一点的说:系统代号),所以我们先了解下新版本的系统代号:

      使用如下命令:

      lsb_release -c

      得到本系统的系统代号,如下图所示:

      

      我们可以看到新版本的Ubuntu系统代号为bionic

      同样的我们也可以得到之前任意版本的系统代号:

      Ubuntu 12.04 (LTS)代号为precise。

      Ubuntu 14.04 (LTS)代号为trusty。

      Ubuntu 15.04 代号为vivid。

      Ubuntu 15.10 代号为wily。

      Ubuntu 16.04 (LTS)代号为xenial。

      所以这也就解释了为什么我们百度出来的那么多方案里面内容不尽相同的原因,因为他们更改apt安装源时用的系统不一样。

      4.将原有的内容注释掉,添加以下内容(或者你把里面内容修改成下面的就可以,但是不能有除了以下内容的有效内容)

      deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

      deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

      deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
    二、现在就可以运行sudo apt-get update更新更新表,然后运行sudo apt-get upgrade更新软件

    三、sudo apt-get install python3

    四、如果没有pip    运行sudo apt-get install python3-pip

    五、不想乱的话就撞上virtualenv吧,sudo pip3 install virtualenv

      这个sudo可以避免安装完virtualenv找不到的尴尬,这里加个sudo就可以省去百度、改乱七八糟的步骤了

  • 相关阅读:
    Asp.net2.0 中自定义过滤器对Response内容进行处理 dodo
    自动化测试工具 dodo
    TestDriven.NET 2.0——单元测试的好助手(转) dodo
    JS弹出窗口的运用与技巧 dodo
    ElasticSearch 简介 规格严格
    修改PostgreSQL字段长度导致cached plan must not change result type错误 规格严格
    Linux系统更改时区(转) 规格严格
    mvn编译“Cannot find matching toolchain definitions for the following toolchain types“报错解决方法 规格严格
    ElasticSearch 集群 & 数据备份 & 优化 规格严格
    Elasticsearch黑鸟教程22:索引模板的详细介绍 规格严格
  • 原文地址:https://www.cnblogs.com/python001-vip/p/12179582.html
Copyright © 2020-2023  润新知