THIS PAGE HAS BEEN TRANSLATED AUTOMATICALLY - MAY CONTAIN INCORRECT OR OUTDATED INFORMATION.
- Python * is a high-level programming language. On Serv00.com servers it is possible to run pages and applications based on this language.
The default version of * Python * on Serv00.com servers is
version 3.8 - invoking the command
python will start the interactive language interpreter in this version. In addition, the following commands are also available:
python3.10 to run the given version of * Python *.
Virtualenv is a tool for creating isolated * Python * environments. Using
Virtualenv solves the basic problem with different versions of additional language libraries and permissions - virtual environments are created entirely in the user's home directory, which (together with the tools provided by
virtualenv as standard) allows full, independent
management of installed modules .
Before installation, please enable the use of your own software - Binexec.
In this tutorial, the
/ usr / home / LOGIN / .virtualenvs directory has been created and used to collect all user-created
virtual environments. A new directory can be created with the command
mkdir / usr / home / LOGIN / .virtualenvs.
Creating a virtual environment
A virtual environment can be created by running the command
virtualenv in a selected directory, specifying
environment name as a parameter:
$ cd /usr/home/LOGIN/.virtualenvs $ virtualenv environment_name New python executable in envname / bin / python3.8 Also creating executable in enviroment / bin / python Installing setuptools, pip ... done.
Such command invocation creates a
new virtual environment using the
system default python version. You can use the
-p flag to indicate
other executable, which consequently creates a
virtual environment using a different version of * Python *:
$ cd /usr/home/LOGIN/.virtualenvs $ virtualenv environment_name -p /usr/local/bin/python2.7 Running virtualenv with interpreter /usr/local/bin/python2.7 Using base prefix '/ usr / local' New python executable in envname / bin / python2.7 Also creating executable in enviroment / bin / python Installing setuptools, pip ... done.
Activating the virtual environment
To run the script with the interpreter, it is enough to specify the path to the new executable
/ usr / home / LOGIN / .virtualenvs / environment_name / bin / python), however to facilitate the use of
script bin / activate, the loading of which will modify the user environment in such a way as to facilitate the use of the new environment.
$ source /usr/home/LOGIN/.virtualenvs/ environment_name/bin/activate (environment_name) $
prompthas changed. At the beginning, the
name of the virtual environmentin which the user is currently located is given. In this state, it is not necessary to enter the full path to the interpreter, the commands
easy_installwill be executed using the currently selected virtual environment.
You can leave a given environment by issuing the command
When adding a WWW page
python type, you must specify the executable
/ usr / home / LOGIN / .virtualenvs / environment_name / bin / python so that the
virtualenv environment is used to support the page.
Some packages installed with the
pip command require additional variables for the compilation to be successful. Before running
pip install package, do:
export CFLAGS = "- I / usr / local / include" export CXXFLAGS = "- I / usr / local / include"
GCC, so to select it, execute the following commands:
export CC = gcc export CXX = g ++
Another available version of
GCC may also be indicated.
If you exceed the limit of system processes when installing packages using
pip, you should issue the following commands:
export MAX_CONCURRENCY = 1 export CPUCOUNT = 1 export MAKEFLAGS = "- j1"
And try the installation again.
Restart the application
Process limit for Phusion Passenger
Possibility to set the number of processes for
python pages. Command syntax:
devil www options DOMAIN processes <Quantity>
- * DOMAIN * stands for the python type WWW domain
- * QUANTITY * - number of processes in the range
from 1 to 80% of system processes of the hosting account
The option is also available in the DevilWEB panel:
WWW pages ➡
Process limit ➡ enter a new value and save the changes with the
Save changes button.
All files under
/usr/home/LOGIN/domains/DOMAIN/public_python/public are handled as static files. It is best to put all pictures, scripts, styles, etc. in this directory. Requests to files in this directory will not be processed by Python processes and will not burden the interpreter. For example, the file
/usr/home/LOGIN/domains/DOMAIN/public_python/public/robots.txt will be available at
Setting a variable from the SSH level with visibility for the application launched by Passenger is possible by adding variables to the
~/.bash_profile file (e.g.
export TESTENV = 1).
Variables will not be used from
Do not delete the
logs directory, it may cause problems with
The error logs are saved to the
error.log file in the
If there are no requests to the site for 24 hours, the application is automatically shut down and started again automatically on the first next visit. In the event of a change in the website configuration, the application is also automatically shut down and launched the next time the website is accessed for the first time.