centos7.4 部署flask项目之 虚拟环境
centos7.4
sudo su 或者
linux下通过useradd方式创建新用户icon时,都会将所有的配置文件从/etc/skel复制到/home目录的新用户录下。但现在这个icon目录是新建立的,空的,那么就要复制/etc/skel这个目录的文件到/home/icon中 。
-
cd /etc/skel
ls -a
显示. … .bash_logout .bash_profile .bashrc
cp .bash_logout /home/icon
cp .bash_profile /home/icon
cp .bashrc /home/iconn
su icon -
yum -y install epel-release
yum -y install python-pip
报错安装不了或者有gcc类似的一些依赖问题:
https://www.linuxidc.com/Linux/2019-08/160310.html
参考这篇文章,几个步骤替换为阿里云的yum源
安装完成之后清除cache:
yum clean all
pip --help 查看一下是否安装成功!
3. 虚拟坏境 virtualenv和virtualenvwrapper
pip list ------看是否安装了virtualenv和virtualenvwrapper,没有的话:
pip install virtualenv ------这个应该没啥问题,重要的时virtualenvwrapper的配置:
pip install virtualenvwrapper-------mkvirtualenv venv创建虚拟坏境这样肯定报错:bash: mkvirtualenv: 未找到命令。
which python-------查看python版本>> /bin/python,如果项目使用python3则输入命令which python3
which virtualenvwrapper.sh-------为后面配置做准备。
vi ~/.bashrc -------加入
```
VIRTUALENVWRAPPER_PYTHON=/bin/python
export WORKON_HOME=$HOME/.virtualenvs
source /bin/virtualenvwrapper.sh
```
第一行就是which python的输出的路径
第二行都一样
第三行 which virtualenvwrapper.sh 输出的路径,这是你安装完virtualenvwrapper自动生成的shell脚本。
**source ~/.bashrc** -------运行
mkvirtualenv venv
workon venv切换到虚拟坏境