16.04 系统默认 python3.5,另外 36 的包由于不再支持,因此需要手动编译 python3.6,若需要 python3.8 也需手动编译。
18.04 系统默认 python3.6,可 apt 安装 python3.8
sudo apt install python3.8 sudo apt-get install nfs-common # 目录挂载 sudo apt install python3-pip sudo apt-get install git sudo apt-get install llvm-8 sudo apt-get install libboost-dev sudo apt-get install g++ sudo apt-get install vim sudo apt-get install curl 一般需要将搭建环境的机器上的 /toolchain 和 /home/.virtualenvs/ 两个目录挂载到新机器。18.04 及以上版本 rc.local 不起作用的设置方法:ubuntu18.04设置开机自动启动脚本_ubuntu打开自动执行脚本-CSDN博客
1. 新服务器创建 /home/.virtualenvs 目录。
2. 挂载。
# 挂载命令 sudo mount -t nfs 192.168.9.X:/toolchain /toolchain sudo mount -t nfs 192.168.9.X:/home/.virtualenvs/ /home/.virtualenvs/ 3. 挂载命令写入 /etc/rc.local。
#!/bin/bash -e # # rc.local # # This script is executed at the end of each multiuser runlevel. # Make sure that the script will "exit 0" on success or any other # value on error. # # In order to enable or disable this script just change the execution # bits. sudo mount -t nfs 192.168.9.X:/toolchain /toolchain sudo mount -t nfs 192.168.9.x:/home/.virtualenvs/ /home/.virtualenvs/ sudo dpkg -r sdk,sudo dpkg -r driver sudo dpkg -i Driver,sudo dpkg -i SDK(手动指定安装包) # 1. 查看本地是否已有环境 virtualenv --version # 2. 若没有需自行安装,建议装到系统环境,其他用户可以一起用 sudo pip3 install virtualenv sudo pip3 install virtualenvwrapper # 3. 安装检查是否安装成功 mkvirtualenv --version # 4. 若找不到命令需如下配置 mkdir /home/用户名/.virtualenvs # 5. 将以下信息放到 ~/.bashrc 中 export WORKON_HOME=/home/用户ly名/.virtualenvs VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3 source /usr/local/bin/virtualenvwrapper.sh # whereis virtualenvwrapper.sh 查找 ###### python环境 export PYTHONPATH=/home/c/ly/python:$PYTHONPATH # 6. 挂载共享目录 sudo mount -t nfs 192.168.9.X:/home/.virtualenvs/ /home/用户名/.virtualenvs/ # 若常用的话,可放到 rc.local 中 # 7. 检查是否挂载成功,以及虚拟环境能否使用 # 检查是否挂载成功 df -h # 虚拟环境列表 workon # 虚拟环境使用,注意python版本 workon 环境名称