文章目录
显示
Linux安装Python3
- pycharm
- python3
- pip
- virtualEnv
登录服务器后,输入Python,发现默认安装的是Python2.7.5版本
一、LinuxPython环境环境安装
环境依赖的安装:
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel mysql-devel gcc gcc-devel python-devel
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
下载Python3.7
cd /usr/local
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
解压
tar -zxvf Python-3.7.0.tgz
创建存放地址
mkdir /usr/local/python37
编译
cd Python-3.7.0
./configure --prefix=/usr/local/python37
执行make
make && make install
安装成功,测试一下,输入python3
/usr/local/python37/bin/python3.7
可以看到是Python3.7
:
创建一个快捷方式:
ln -s /usr/local/python37/bin/python3.7 /usr/bin/python3
创建test.py
测试安装是否成功:
装pip3
ln -s /usr/local/python37/bin/pip3.7 /usr/bin/pip3
装virtualenv
pip3 install virtualenv
ln -s /usr/local/python37/bin/virtualenv /usr/bin/virtualenv
#创建虚拟环境
virtualenv -p /usr/bin/python3 xuhss
#激活虚拟环境
激活虚拟环境:source xuhss/bin/activate
查看Python的位置
which python
which python3
二、虚拟机Centos如何和主机共享目录
设置共享文件夹(/dev/cdrom)
重启虚拟机
创建文件夹存放文件
mkdir /mnt/cdrom
挂载目录
mount /dev/cdrom /mnt/cdrom
拷贝文件
cp -R /mnt/cdrom /usr/local/src/VBoxAdditions
安装环境
yum install -y gcc gcc-devel gcc-c++ gcc-c++-devel make kernel kernel-devel bzip2
安装增强环境
/usr/local/src/VBoxAdditions/VBoxLinuxAdditions.run install
创建服务器源码文件夹
mkdir /home/www
关联文件
mount -t vboxsf XuhssFlask /home/www