The current Python version of Linux is basically 2.7 By default. If Python or later is installed on the system
Python3.3, but using Pip or easy_install to install the module of python3 is not very good. Using virtualenv is much more convenient,
A good way to install the pypy environment is to use virtualenv. The procedure is as follows:
virtualenv -p /path/to/python3 dir_name
The premise is that you have installed virtualenv as follows:
Sudo apt-Get install Python-virtualenv or sudo Pip install virtualenv.
Using virtualenv will generate the dir_name directory in the current directory. In this way, the virtual environment of python3 is generated,
After all, virtualenv has introduced a lot on the Internet.
In the same way, we use virtualenv-P/path/to/pypy virtualpypy to create a virtualpypy directory. Enter
Virtualpypy, and then source bin/activate. You can use Pip or easy_install to install the library. For example, if flask is installed,
To make uwsgi run in a little trouble, you need to use Pip to install uwsgi: Pip install uwsgi in the virtual environment. This will compile
Suitable for pypy uwsgi.
The uwsgi. xml file is as follows:
1 <uwsgi> 2 <socket>0.0.0.0:6001</socket> 3 <listen>20</listen> 4 <chdir>/path/to/virtualpypy</chdir> 5 <pythonpath>/path/to/virtualpypy</pythonpath> 6 <virtualenv>/path/to/virtualpypy</virtualenv> 7 <processes>3</processes> 8 <master>true</master> 9 <pidfile>/path/to/virtualpypy/uwsgi.pid</pidfile>10 <wsgi-file>/path/to/virtualpypy/application.py</wsgi-file>11 <profiler>true</profiler>12 <memory-report>true</memory-report>13 <enable-threads>true</enable-threads>14 <no-site>true</no-site>15 <pypy-lib>/path/to/virtualpypy/libpypy-c.so</pypy-lib>16 <logdate>true</logdate>17 <limit-as>6048</limit-as>18 </uwsgi>
Note row 15th, if there is no libpypy-c.so for this dynamic link library, uwsgi-x uwsgi. XML will report an error.
We need to download or compile a libpypy-c.so.
Download http://projects.unbit.it/downloads/pypy/libpypy-c-x86_64.so
Compile the need to download the pypy source code tarball, I use the pypy-2.3.1,
./rpython/bin/rpython -Ojit --shared --gcrootfinder=shadowstack pypy/goal/targetpypystandalone
I spent more than one hour compiling the 4G memory on 64-bit machines. Two important files, libpypy-c.so and pypy-C, are generated.
Since compilation is required on the Internet, this is the problem because the Python version installed with APT-get is the same as the one downloaded from the Internet.
The following error may occur due to different libpypy-c-x86_64.so versions:
Debug: operationerror:
Debug: operror-type: assertionerror
Debug: operror-value:
So if there is no error best, error or compile a, put the libpypy-c.so in the dynamic link path of the default path or
LD_LIBRARY_PATH environment variable. Use virtualenv-P/path/to/pypy-C virtualnew to create the virtual environment,
Install flask, Django, and uwsgi in the same way as above.
Wed Jun 25 00:41:26 2014 - uwsgi socket 0 bound to TCP address 0.0.0.0:6001 fd 3Initialized PyPy with Python 2.7.6 (32f35069a16d819b58c1b6efb17c44e3e53397b2, Jun 23 2014, 15:54:22)[PyPy 2.3.1 with GCC 4.8.2]PyPy Home: /path/to/virtualnewWed Jun 25 00:41:27 2014 - your server socket listen backlog is limited to 20 connectionsWed Jun 25 00:41:27 2014 - your mercy for graceful operations on workers is 60 secondsWed Jun 25 00:41:27 2014 - mapped 291072 bytes (284 KB) for 3 coresWed Jun 25 00:41:27 2014 - *** Operational MODE: preforking ***Wed Jun 25 00:41:27 2014 - *** no app loaded. going in full dynamic mode ***Wed Jun 25 00:41:27 2014 - *** uWSGI is running in multiple interpreter mode ***Wed Jun 25 00:41:27 2014 - spawned uWSGI master process (pid: 1566)Wed Jun 25 00:41:27 2014 - spawned uWSGI worker 1 (pid: 1569, cores: 1)Wed Jun 25 00:41:27 2014 - spawned uWSGI worker 2 (pid: 1570, cores: 1)Wed Jun 25 00:41:27 2014 - spawned uWSGI worker 3 (pid: 1571, cores: 1)
Pypy can be used properly at last. The above two lines of red show that pypy 2.3.1 corresponds to Python 2.7.6. I have
It is not only faster than python in running flask, Django, and other projects (I have introduced pypy and
Python calculates the Fibonacci series time, which is far from a street. It is developed in Python (rpython ).
Just like many other advanced languages such as Java and go, although originally developed by C, they finally come back to explaining themselves.
Although pypy still has many problems, although the official python is still developed in C, I hope pypy can develop better.
It is only for your speed and only for your python interpreter.