Ubuntu 命令行更改源

在修改source.list前,最好先备份一份

软件源的地址配置文件在 /etc/apt/sources.list

执行备份命令

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

执行命令打开source.list文件:

可以用vim,gedit,atom等工具打开

sudo vim /etc/apt/sources.list

内容如下

# deb cdrom:[Ubuntu 18.04.3 LTS _Bionic Beaver_ - Release amd64 (20190805)]/ bionic main restricted

# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic main restricted ## Major bug fix updates produced after the final release of the
## distribution.
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates main restricted ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates universe
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe ## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-updates multiverse ## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://us.archive.ubuntu.com/ubuntu/ bionic-backports main restricted universe multiverse ## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted
# deb-src http://security.ubuntu.com/ubuntu bionic-security main restricted
deb http://mirrors.aliyun.com/ubuntu/ bionic-security universe
# deb-src http://security.ubuntu.com/ubuntu bionic-security universe
deb http://mirrors.aliyun.com/ubuntu/ bionic-security multiverse
# deb-src http://security.ubuntu.com/ubuntu bionic-security multiverse

pip 源的配置

Win 下, %HOMEPATH%, pip/pip.ini

Ubuntu 下, ~/.pip/pip.conf

内容如下

[global]
index-url = http://mirrors.aliyun.com/pypi/simple/
[install]
trusted-host = mirrors.aliyun.com

虚拟环境配置

环境:

  • Ubuntu 18.04
  • Python3
如果系统同时安装了python2和3版本,请执行下面的命令

pip2 install virtualenv

pip2 install virtualenvwrapper

pip3 install virtualenv

pip3 install virtualenvwrapper

# Win
pip install virtualenvwrapper-win

使用pip3安装virtualenvvirtualenvwrapper两个包,ubuntu18.04中,用户使用pip安装的包在~/.local/下,在.bashrc中添加的配置如下:

# Python Virtualenv Settings

export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
source ~/.local/bin/virtualenvwrapper.sh

使用mkvirtualenv创建虚拟环境时,报错如下:

roc@roc-ThinkPad-E455:~$ mkvirtualenv remote
ERROR: virtualenvwrapper could not find virtualenv in your path

提示virtualenv 不在环境中,需要在配置文件添加virtualenv的路径进去,具体配置如下:

# Python Virtualenv Settings

export WORKON_HOME=~/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3
# 指定virtualenv的路径
export VIRTUALENVWRAPPER_VIRTUALENV=~/.local/bin/virtualenv
source ~/.local/bin/virtualenvwrapper.sh

然后重新加载.bashrc文件即可

Ubuntu源、Python虚拟环境及pip源配置的更多相关文章

  1. python虚拟环境 + 批量pip + 换源

    python虚拟环境 + 批量pip + 换源 虚拟环境 曾经我是一个小白,不管运行什么项目都用一个环境,后来项目多了,有的是Django1.11的有的是Django2的,有的项目只能在3.6上运行, ...

  2. Python虚拟环境的安装和配置-virtualenv与windows下多个python版本共存

    Python虚拟环境的安装和配置-virtualenv与windows下多个python版本共存 windows下多个python版本共存 https://www.python.org/downloa ...

  3. python:更改pip源

    windows更改pip源 cmd echo %APPDATA% 打开目录 创建文件夹pip 创建pip.ini文件 [global] timeout = 60 index-url = http:// ...

  4. Python入门 更换pip源的方法

    pip国内的一些镜像 阿里云 http://mirrors.aliyun.com/pypi/simple/ 中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple ...

  5. Python 更换国内pip源

    pip国内的一些镜像: 阿里云 http://mirrors.aliyun.com/pypi/simple/   中国科技大学 https://pypi.mirrors.ustc.edu.cn/sim ...

  6. python为何需要虚拟环境--Python虚拟环境的安装和配置-virtualenv

    一 虚拟环境 virtual environment 它是一个虚拟化,从电脑独立开辟出来的环境.通俗的来讲,虚拟环境就是借助虚拟机docker来把一部分内容独立出来,我们把这部分独立出来的东西称作“容 ...

  7. mac 下 python 虚拟环境的安装和配置

    前言:继续安装中,这节记录 mac 安装 python 虚拟环境,多版本共存... 1. 安装 pip -- python的包管理工具: sudo easy_install pip 安装成功,出现下面 ...

  8. Python虚拟环境中pip install时没有权限问题

    virtualenv Permission denied 新建的python虚拟环境的目录的所属者必须是当前用户,才不会出现这种错误 比如 virtualenv py27 sudo chown zzf ...

  9. PYTHON指定国内PIP源

    一.LINUX: vi ~/.pip/pip.conf 输入内容: [global]index-url = http://pypi.douban.com/simple/[install]trusted ...

随机推荐

  1. mini-web框架-装饰器-总结1(5.3.1)

    @ 目录 1.说明 2.代码 关于作者 1.说明 原则:开放封闭 可以扩展,但是不可以修改.也就是说软件对扩展开放,对修改关闭. 运用技术:闭包 一共两种方法,一个使用闭包,一个使用类 使用多个装饰器 ...

  2. 用Python从头开始构建神经网络

    神经网络已经被开发用来模拟人脑.虽然我们还没有做到这一点,但神经网络在机器学习方面是非常有效的.它在上世纪80年代和90年代很流行,最近越来越流行.计算机的速度足以在合理的时间内运行一个大型神经网络. ...

  3. RestTemplate发起http请求中文乱码问题解决方案

    RestTemplate restTemplate = new RestTemplate(); HttpHeaders headers = new HttpHeaders(); MediaType t ...

  4. [LeetCode]求两个链表的焦点--Intersection of Two Linked Lists

    标题题目地址 1.解题意 求解两个链表的焦点,这个交点并不是焦点的值相等,而是需要交点之后的数据是完全相等的. 落实到java层面,就是交点处的对象是同一个对象即可. ps:我最开始没有读懂题目,然后 ...

  5. [Machine Learning] 多变量线性回归(Linear Regression with Multiple Variable)-特征缩放-正规方程

    我们从上一篇博客中知道了关于单变量线性回归的相关问题,例如:什么是回归,什么是代价函数,什么是梯度下降法. 本节我们讲一下多变量线性回归.依然拿房价来举例,现在我们对房价模型增加更多的特征,例如房间数 ...

  6. Qt学习笔记-安装phonon模块

    如果想要运行使用Qt中的phonon写的程序,需要满足一下条件:Qt基本库.Qt phonon库.phonon_backend(后端插件)和多媒体播放后台.下面以linux(Fedora 12)系统. ...

  7. JavaDailyReports10_18

    学习内容:HTML基本知识 1.通常标记具有默认属性,当一个标记中只有标记名时,使用默认属性. 2.HTML标记有两种:单标记和双标记,单标记的语法格式:  <标记名称/> 3.不同的属性 ...

  8. 学习DOS,个人笔记

    在win中\表示根目录,  在linux中/表示根目录         注意: 有些家庭版的系统会选择性的调用命令的,有的命令虽然有那个文件,但是不能使用.....     dir 命令   英语全称 ...

  9. Java源码系列4——HashMap扩容时究竟对链表和红黑树做了什么?

    我们知道 HashMap 的底层是由数组,链表,红黑树组成的,在 HashMap 做扩容操作时,除了把数组容量扩大为原来的两倍外,还会对所有元素重新计算 hash 值,因为长度扩大以后,hash值也随 ...

  10. 消息队列 ---常用的 MQ 中间件

    目前市面上比较常用的 MQ(Message Queue,消息队列)中间件有 RabbitMQ.Kafka.RocketMQ,如果是轻量级的消息队列可以使用 Redis 提供的消息队列,其中 Redis ...