Is there any difference between qpython and python? Which one is better, qpython or qpython3?

Hello everyone, I will answer the following questions for you. Is there any difference between qpython and python? Which is better, qpython or qpython3? Now let's take a look!

 

Super magic weapon...

I believe that most Android users have used Qpython, a mobile Python editor, right? I have also studied this tool for a while before, but I was extremely disappointed with it because of a simple crawler. First of all, Qpython does not support the lxml module, and those who know python crawlers know that many crawlers rely on this module for html parsing. Even in the Qpython article, I use bs4 with the html.parser parsing plug-in to skip the lxml dependency. But it's just a way to circumvent, I need to find a tool that can really solve this problem from the source.

Furthermore, Qpython is at best a simple python editor for mobile phones. If you want to turn your mobile phone into a python development environment, then Qpython is still far behind....

So, Termux came into being....

Termux is not only used as our python developer desktop, but also can help you learn and use Linux system by installing various plug-ins. Some people may ask, why do you want to develop python on your mobile phone, because too many IT companies are isolated from internal and external networks for confidentiality and security considerations, and they are not allowed to bring their own computers into the venue...

Introduction to Termux

Termux is a Linux environment emulator for the Android terminal. The main thing is that it can be installed and used directly without root. Additional tools can be custom installed using the apt package manager or the pkg command recommended by this tool. Why other tools? You can try all the tools you can think of under Linux, and most of them can be installed directly, but there are also some tools that require you to make a turn, such as installing the mysql database on your mobile phone!

Termux Wiki official website: https://wiki.termux.com/wiki/Main_Page

Termux Wiki

You can see the recommended download methods on the official website are Google Play and F-Droid. Google Play is too troublesome to install on the phone, so F-Droid is recommended, although it is relatively slow...Of course you can download the apk file of Termux offline, although there is no way to get updates. It is relatively simple to install Guoguocheng. Download F-Droid, search for Termux after the installation is complete, and download it.

Python Developer Desktop

I just talked about the brief introduction and download method of Termux, then after the download is complete, only this tool is installed, not our Python developer desktop. After the Termux installation is completed, the first entry will carry out related initialization work, just wait for 1-2 minutes (you need to download tools online at this time). Screenshot below:

Install Termux.png

After that it's time to get into our DIY time!

Update source:

In order for us to get the latest plug-in information, we need to update the mirror source list

pkg update

pkg upgrade

pkg install python python-dev

Install python and pip

The system installed the latest python3.7.4 version for us, keeping up with fashion trends....

pkg install python python-static

pip install --upgrade pip

Install dependent plugins

This step has been blocked for a long time. You can see that there are many help posts for the installation of lxml on the Internet, whether it is a linux system or our Termux.

lxml installation error

According to the answers of many enthusiastic netizens, I tried to install plug-ins and other solutions without success.

Most of the error reports are that the libxml2 plug-in is not installed, but it is clearly installed, and then consult the information to learn that the use of python to use this plug-in needs to be compiled through the clang plug-in before it can be used, but after installation, there is a prompt that the conv.h file cannot be obtained, etc. . This problem stuck my time intermittently for two days. I just uninstalled and installed Termux a few times, and I only have 5G left after 20G of traffic per month... Finally, I found all the plug-ins and summarized them for everyone:

pkg install libxml2 libxslt libiconv libllvm clang libzmq libc++

pip install lxml

lxml installed successfully

Directory description:

First, we enter termux-setup-storage to share the phone directory with termux. After completion, there will be an additional storage folder under the home directory.

Catalog description

Friends who know Linux should be more aware of the problem of creating links and mount points. The directory of the mobile phone is in /data/data/com.termux/files/home/storage/shared of Termux. Then in the same way, we can map the code directory of the mobile phone to Termux. The command is as follows:

ln -s /data/data/com.termux/files/home/storage/shared/Codes_Repository ~/Codes

Then, we throw the script Novels.py of the novel downloader into the Codes_Repository of the mobile phone, and then go to Termux to see if it is synchronized

directory sharing

Inadvertently exposed my Mate 20X, haha... The reason why I bought the 7.2-inch 20x was to make the phone into a python development tool.

Optimize editor

Everyone knows that when developing python in a Linux environment, the great gods recommend vi, and other tools are not high-end...

So how to optimize our editor? Install vi's brother vim, and install vim-python code for developing python under vim

# Install vim vim-python

pkg install vim vim-python

# Create a vim configuration file

vim .vimrc

# Add vim configuration file

set fileencodings=utf-8,gb2312,gb18030,gbk,ucs-bom,cp936,latin1

set enc=utf8

set fencs=utf8,gbk,gb2312,gb18030

# keep

:wq

# Effective immediately

source .vimrc

Editor effect display

Let's take a look at the encoding effect of vim-python:

vim-python

vim-python

code run

How about it, for the native vim, the display effect is not bad...so is it a show? try it out

Module installation and use

It can be seen that the first run prompts that the requests module is indeed requested. After installing it through pip, execute it again, perfect...

Use git under Termux

Since it is going to be a python developer desktop, how can the use of git tools be missing?

pkg install git

git config --global user.name "Usernam"

git config --global user.email "email-addr"

git clone https://github.com/KingUranus/FlaskTests.git

Git

image.png

image.png

Now we download the code from the phone, install it...

# If you are installing pipenv, you need to install it first

pip install pipenv

# clone code

git clone https://github.com/BreezePython/WeatherForecast.git

# Enter the code directory

cd WeatherForecast

# Install virtual machine and dependent modules

pipenv install

# enter the virtual machine

pipenv shell

# start flask

flask run

From installation to use, you don't need to pay attention to what modules are involved in the virtual environment and how to install them. Yes, pipenv is so simple and rude + brainless! Put a few pictures:

Download code and install virtual environment

Not to mention, the little snake installed is quite cute....

Install the plugin and start flask

Finally see if the phone is working properly:

mobile phone running

You said that this tool is not as fierce as a tiger in one operation, it makes me scared, haha...

The End

OK, that's all for today's content. If you think the content is helpful to you, you can click "Looking" in the lower right corner of the article.

Reply to the official account for Android development, and you can get the offline installation package of Termux and the script for downloading novels. From then on, it will take you on the road of python super god!

Guess you like

Origin blog.csdn.net/mynote/article/details/132185533
Recommended