Create a virtual environment on the server centos7 of Django's personal blog website, djangocentos7

Source: Internet
Author: User
Tags virtualenv

Create a virtual environment on the server centos7 of Django's personal blog website, djangocentos7
1. Install virtualenv

Installation Method

Pip install virtualenv # install pip3 install virtualenv # install it in python2
2. Install virtualenvwrapper

Installation Method

Pip install virtualenvwrapper # install it in python2 pip3 install virtualenvwrapper # install it in python3

Note that both of them must be installed. If only python3 is installed, the workon command cannot be used.

Set

Locate

find / -name virtualenvwrapper.sh

We will find two locations.

/Usr/local/python3/bin/virtualenvwrapper. sh #/usr/bin/virtualenvwrapper. sh # In python3

Later we will use the location in python3.

Edit configuration file

cdvim ~/.bashrc

Add the following two commands to the end and specify the location of the virtual environment.

export WORKON_HOME=~/.virtualenvssource /usr/local/python3/bin/virtualenvwrapper.sh

Execute. bashrc to make the file take effect

source ~/.bashrc

Create a virtual environment

mkvirtualenv -p /usr/bin/python3 blog_env_py3

In this way, the virtual environment blog_env_py3 is created.

You can run the workon command to view the directories of all virtual environments and enter the virtual environment.

workon blog_env_py3
3. Install the dependency package in the virtual environment

Go to blog_test in windows and run the following command to export all packages to be installed:

pip freeze > requirements.txt

Use winscpsoftware to import the generated requirements.txt to linux.

Go to the virtual environment blog_env_py3 in linux and run the following command to install all the packages.

pip install -r requirements.txt

When mysqlclient = 1.3.12 is installed, an error is reported. You need to install another dependency package.

yum install mysql-devel

Check the installed package through pip list.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.