CentOS 7 virtualenv create environment && run the project python3 and python2

(A) may be installed virtualenv yum -y install python-virtualenv or pip install python-virtualenv

(B) in hope that the path to create env

virtualenv env-python27

It can directly specify the path to create the corresponding python

virtualenv --python=/usr/local/python3/bin/python3.6 python36

 
 

Measured default virtual environment does not depend on the system environment of global site-packages. For example, the system environment MySQLdb module is installed in the virtual environment will be prompted to import MySQLdb ImportError. If you want to rely on the system environment of third-party packages, you can use the parameter --system-site-packages. Further, the use virtualenvwrapper toggleglobalsitepackages command control whether the current environment global site-packages.

virtualenv --system-site-packages env1

 

(E) the installation pip


yum upgrade python-setuptools

yum install python-pip (upgrade pip: python -m pip install --upgrade pip)

(Vi) all installed Python project dependencies list

1 Installation tools

pip install pipreqs

2, into the python home directory project

pipreqs ./

3, completion of the above command will generate requirements.txt

4、sudo pip install -r requirements.txt即可

(Vii) to run the project

1, activation of the environment

Into the environment directory source bin / activate

2, running start

 (1)django

    python manage.py runserver 192.168.1.123:8888

 (2) flask

Installation gunicorn
PIP install gunicorn
run flask project
gunicorn -w 3 -b 0.0.0.0:8000 microblog: app
running in the background flask project
gunicorn -w 3 -b 0.0.0.0:8000 microblog: app --daemon

 

yum install python-pip (upgrade pip: python -m pip install --upgrade pip)

Guess you like

Origin www.cnblogs.com/360minitao/p/12085329.html
Recommended