你好! 如果你是第一次通过VMware这个平台创建Ubuntu虚拟机,那么我相信下面这些文件会帮你省些时间
Ubuntu18.04官方镜像:ubuntu-18.04-desktop-amd64
amd64官方镜像链接:https://pan.baidu.com/s/149XCHS8C0-f1YML7umJhmA
提取码:tckr
VMware Workstation Pro 14安装程序:VMware-workstation-full-14.1.2-8497320
安装包及激活码链接:https://pan.baidu.com/s/1Mp33qzP6FxLfBwOvUreL4Q
提取码:crzl
1.VMware 14.1.1安装ubuntu18.04教程及安装 VMware Tools:
2.Ubuntu 18.04 LTS 安装搜狗输入法:
https://blog.csdn.net/u012123511/article/details/82352357
https://blog.csdn.net/fx_yzjy101/article/details/80243710
3.虚拟机中Ubuntu下安装vim及配置文件和插件:
4.Ubuntu18.04下VIM安装及配置:
因为刚安装好的Ubuntu在更新软件的时候使用的是国外软件源,下载速度较慢,所以将软件源更改成国内源可以提高下载速度。
Ubuntu18.04虚拟机换源:
(1)备份/etc/apt/sources.list文件
sudo cp /etc/apt/sources.list /etc/apt/sourses.list.backup
(2)在/etc/apt/sources.list 文件并添加国内源
vim打开保存源内容的文件:
sudo vim /ect/apt/sources.list
将国内的源地址复制粘贴到sources.list中,下面提供的源都可以复制到里面
附几种国内的源
清华源:
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
阿里源:
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
中科大源:
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src https://mirrors.ustc.edu.cn/ubuntu/ bionic-proposed main restricted universe multiverse
163源:
deb http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.163.com/ubuntu/ bionic-backports main restricted universe multiverse
(3)保存源文件退出
按ESC 进入命令模式 其次同时按下shift和冒号,则左下角会出现冒号,最后编辑wq!回车键即保存好。
更改完成之后执行以下命令对新的源进行更新
apt update
apt upgrade
(4)其他的一些apt命令
sudo apt-get update 更新源
sudo apt-get install package 安装包
sudo apt-get remove package 删除包
sudo apt-cache search package 搜索软件包
sudo apt-cache show package 获取包的相关信息,如说明、大小、版本等
sudo apt-get install package --reinstall 重新安装包
sudo apt-get -f install 修复安装
sudo apt-get remove package --purge 删除包,包括配置文件等
sudo apt-get build-dep package 安装相关的编译环境
sudo apt-get upgrade 更新已安装的包
sudo apt-get dist-upgrade 升级系统
sudo apt-cache depends package 了解使用该包依赖那些包
sudo apt-cache rdepends package 查看该包被哪些包依赖
sudo apt-get source package 下载该包的源代码
sudo apt-get clean && sudo apt-get autoclean 清理无用的包
sudo apt-get check 检查是否有损坏的依赖
Ubuntu18.04版本里面自带了最新的Python3.6.5版本,所以在安装Python虚拟环境时需注意:
pip3 install virtualenv # python虚拟环境
pip3 install virtualenvwrapper # 封装了虚拟环境,支持一些简化命令
如果没有安装pip3,则执行首先 sudo apt install python3-pip 安装
然后再执行安装两个包:
安装后通过 pip3 list 查看是否安装成功
Python2安装pip步骤类似(在Ubuntu16.04中内置了python2,可直接升级安装virtualenv即可)
1.升级python包管理工具pip
pip install --upgrade pip
备注:当你想升级一个包的时候 pip install --upgrade 包名
2.python虚拟环境安装
sudo apt-get install python-virtualenv
sudo easy_ install virtualenvwrapper
在使用ubuntu18.04搭建虚拟环境时,按照16.04的方法:
安装虚拟命令:
sudo pip install virtualenv
sudo pip install virtualenvwrapper
在Ubuntu中,升级了pip,再次使用pip安装相关的python包的时候就有可能出现以下错误:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
from pip import main
ImportError: cannot import name main
解决办法:
pip文件在/usr/bin目录下,cd /usr/bin 进入该目录,
sudo gedit pip 用gedit对pip文件进行以下修改并保存
把下面的三行:
from pip import main
if __name__ == '__main__':
sys.exit(main())
修改为以下三行:
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())
上述工具装好后找不到mkvirtualenv命令,需要执行以下环境变量设置。
创建目录用来存放虚拟环境
1.mkdir $HOME/.virtualenvs
2.在~/.bashrc中添加两行指令
# 在末尾添上(去掉注释)
# export WORKON_HOME=$HOME/.virtualenvs
# source ~/.local/bin/virtualenvwrapper.sh
3.vim ~/.bashrc打开文件
4.Vim编辑后cat一下修改结果:
注释:
在Ubuntu18.04中的virtualwarpper执行脚本位置和以前的版本位置不同,所以再执行该步骤的时候需要特别注意一下:
# 以前的配置路径(ubuntu16.04)
# source /usr/local/bin/virtualenvwrapper.sh
ubuntu18.04中的配置路径:
# source ~/.local/bin/virtualenvwrapper.sh
source ~/.bashrc
# 创建虚拟环境mkvirtualenv
mkvirtualenv -p Python2 虚拟环境名称
mkvirtualenv -p Python3 虚拟环境名称
# 查看虚拟环境,并切入到某一个虚拟环境workon
workon 虚拟环境名称
# 退出虚拟环境
Deactivate
# 列出所有虚拟环境
lsvirtualenv
# 删除虚拟环境
Rmvirtualenv 虚拟环境名称
ubuntu18.04创建虚拟环境时提示bash
/usr/local/bin/virtualenvwrapper.sh: 没有那个文件或目录
错误原因:
Ubuntu安装了2.7和3.x两个版本的python,在安装时使用的是sudo pip3 install virtualenvwrapper
在运行的时候默认使用的是python2.x,但在python2.x中不存在对应的模块。
(virtualenvwrapper.sh文件内容如下:):
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then
VIRTUALENVWRAPPER_PYTHON="$(command \which python)"
fi
解决方法:
修改virtualenvwrapper.sh文件
which virtualenvwrapper.sh找到文件路径,在文件路径下:
# /usr/local/bin/virtualenvwrapper.sh
sudo vim virtualenvwrapper.sh
修改:
if [ "$VIRTUALENVWRAPPER_PYTHON" = "" ] then
VIRTUALENVWRAPPER_PYTHON="$(command \which python3)"
fi
以上便是我在创建Ubuntu虚拟机过程中的一些经验,欢迎各位提出意见、建议以及批评,有什么问题欢迎随时讨论交流,谢谢支持~