There have been some problems with deploying Django projects to the server. Here is a summary for future reference, and I hope to help you with the same problems. (Like it if it helps! 😝)

Linux upgrade Python to 3.x


Most of the time you are carrying Python 2.x, and in order to use the new 3.x, you need to upgrade the old version

 # python --version
 Python 2.7.5
Copy the code

The system version is 2.7.5

1. Download the new version

You can choose any version you want, but I’m just demonstrating it here

Wget HTTP: / / https://www.python.org/ftp/python/3.5.2/Python-3.5.2.tgzCopy the code

2. The compression

The tar ZXVF Python -- 3.5.2. TGZCopy the code

3. Install and configure

CD Python - 3.5.2 /. / configureCopy the code

If./configure fails, the compiler is not installed. In this case, you need to upgrade the dependency package

  yum install make gcc gcc-c++ 
Copy the code

then

./configure 
Copy the code

4. Compile and install

 make 
 make install 
Copy the code

5. Verify

# python3 -V
Python 3.5.2
Copy the code

6. Set the default version to 3.x

Ls - al/usr/bin | grep python - rwxr-xr-x mto. 1 root root on December 1, 11216, 2018 abrt - action - analyze - python LRWXRWXRWX. 1 root Root 6 April 30 12:11 python -> python2 LRWXRWXRWX. 1 root root 5 April 30 12:11 python2 -> python2.7 -rwxr-xr-x. 1 root root 7136 April 20 2018 PYTHon2.7Copy the code

Rename the original Python soft link:

   mv /usr/bin/python /usr/bin/python.bak
Copy the code

Link Python to python3:

  ln -s /usr/local/bin/python3 /usr/bin/python
Copy the code

View the results

# python -V
Python 3.5.2
Copy the code

Installation ok

7. Yum

 vi /usr/bin/yum
Copy the code

The #! The/usr/bin/python to #! /usr/bin/python2.7, save and exit

  vi /usr/libexec/urlgrabber-ext-down
Copy the code

The #! The/usr/bin/python to #! /usr/bin/python2.7, save and exit

Error ImportError: No module named PIP — A PIP is required






Python3. x: ImportError: No module named PIP There are many ways to install PIP, but I will only describe mine

Wget https://pypi.python.org/packages/source/p/pip/pip-1.3.1.tar.gz - no - check - certificate tar XVF PIP - 1.3.1. Tar. Gz Python PIP - 1.3.1 / setup. Py installCopy the code

Setuptools Compression requires the (missing) Zlib module error: SetupTools Compression requires the (missing) Zlib Module error: SetupTools Compression requires the (missing) Zlib Module error: SetupTools Compression requires the (missing) Zlib Module error: SetupTools Compression requires the (missing) Zlib Module error

Error: SetupTools Compression requires the (missing) zlib module: SetupTools Compression requires the (missing) zlib module


  yum install zlib
  yum install zlib-devel
Copy the code

Recompile Python (make)

Download the setuptools

CD setuptools-39.2.0 python setup.py installCopy the code

Install PIP after ok

ModuleNotFoundError: No module named ‘_sqlite3’ —- Install sqlite3


The simplest method (under general circumstances can be if you can not Google other methods)

/configure --prefix=/usr/local/sqlite3 make && make installCopy the code

Okay, so that’s it for now, and I’ll add it later. If you have any questions, please leave a message!