Recoding for development is using the latest Python - 3.6 - installing Python 3.6 on your server is a trivial problem compared to trying to create using asynchronous code for Python 2.
But basically: when the idea of consolidating async in Python through the Asyncio API came up, Python 2 was already obsolete a few years ago.
And it’s not getting any less obsolete now.
In the past a library called Trollius was maintained specifically to offer the same functionality as "asyncio" (which then had the codename "Tulip" - "Trollius" is the name of another flower).
So even if you get around the problem of this issue and install some version of Asyncio or library with some compatibility that works in Python 2, this will be of little use, since none of the Async libraries for effective input and output (async versions to serve HTTP, or connect to the database) will work in Python 2. - Not to mention any example of code.
Having said all that, more likely your server has Python 3 -or already installed, or available as a package - is just a matter of writing "python3" instead of Python.
Anyway, your project should make use of a "vitualenv": this is an isolated environment in user folders (not root), which has own versions of each library to be used - (this would render the above error, caused precisely by the installation program wanting to save the asyncio files to a system folder - in /usr/local
) .
So - general recommendations: read some virtualenv documentation. Practice on your local machine - you don’t have to do it right on the server. If your local machine is Windows, put a Linux virtual machine: it’s less complicated to develop. That done, and having started the project, if the version of Python 3 on your server is less than 3.6, Compile a Python 3.6 bvyou even there - Python is an easy-to-compile Relativametne project without interfering with the system’s Python.
Create your Python project with file verses, and in a way that works inside a virtualenv. Ready - at this point you are ready to develop a project that can go to production,and use updated biblitoecas.
updating
The recommendation for async code, or any Python project is to always use the latest stable version. Right now it’s 3.7 and we’re just a few weeks away from the official launch of the 3.8. It is common for people to restrict projects to older versions of the language because of the version of Python3 installed on the servers - even on servers with LTS-like distributions like Centos or Ubuntu, Python can be 3.5 (from 4 years ago and without much of the recent features).
The way to go in such cases is either to install the latest Python3 from an official repository, or to compile your own Python 3 in the destination. This is easier to do than it sounds - my recommendation is to use the project "pyenv" to take care of it. From the moment you have the newest Python, just use it to create the virtual environments (virtualenv or equivalent) of the projects, and it will work without any difference to the native Python3 of the distribution, and with all the dependencies created as a user file, without needing anything from the system, or with root.
The only thing is that the Pyenv documentation does not seem to speak of the system requirements for compiling Python3. Both Ubuntu and other Debian Based, as well as Centos and other Redhat based have the "builddep" directive of the package manager - the command apt builddep python3
(plus apt install libcffi-dev
or equivalent, in case Python system is less than 3.6), in general it is enough to install everything the system needs so that Pyenv can compile Python 3 in any version desired, without giving any error.
It was only added in version 3.4. Why you need to use version 2.7?
– Woss
Well, I’m using python 2.7 on my Crossbar.io server (WAMP/Web Socket router), but I’ve never tried using a different python version than the server. I have to connect my computer to the server
– Rafael de Mattos
Couldn’t use the twisted library?
– Rafael de Mattos