Get the App
SLTechnology News&Howtos  ›  Servers  › 

The processing method of entry-level error reporting in Python

Shulou Source: shulou.com Published: 2022-06-01 03:09:18 09月29日 Update

Python entry-level error reporting methods, I believe that many inexperienced people do not know what to do, so this paper summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

Question 1:Missing parentheses in call to 'print'

Reason: because Python2.X and Python3.X are not compatible.

I installed Python3.X, but I tried to run Python2.X code.

So the above syntax is wrong in python3. In python3, you need to parenthesize the statement after print and write it correctly:

Print ("hello world")

Question 2: create project error, django-admin startproject sundyblog

File "c:\ users\ andy\ appdata\ local\ programs\ python\ python35-32\ lib\ site-packages\ django\ utils\ html.py", line 16, in

From .html _ parser import HTMLParser, HTMLParseError

File "c:\ users\ andy\ appdata\ local\ programs\ python\ python35-32\ lib\ site-packages\ django\ utils\ html_parser.py", line 12, in

HTMLParseError = _ html_parser.HTMLParseError

AttributeError: module 'html.parser' has no attribute' HTMLParseError'

Reason: HTMLParseError is no longer available in pythons3.5

Solution:

Method 1: fallback the python version to 3.3 or 3.4

Method 2: upgrade the django version

> pip3 install django==1.8 # # upgrade django version

C:\ Users\ andy > django-admin startproject sundyblog # # execute again, no error reported

Question 3: using the ImageField field to create a table to report an error

C:\ Users\ andy\ sundyblog > python manage.py makemigrations

SystemCheckError: System check identified some issues:

ERRORS:

Blog.Article.portal: (fields.E210) Cannot use ImageField because Pillow is not installed.

HINT: Get Pillow at https://pypi.python.org/pypi/Pillow or run command "pip install Pillow".

Solution: C:\ Users\ andy\ sundyblog > pip install-I https://pypi.douban.com/simple/ Pillow

Looking in indexes: https://pypi.douban.com/simple/

Collecting Pillow

Downloading https://pypi.doubanio.com/packages/0f/fe/0979c8d6fa0c986e4603e5396904945b44f93ff9e346ee5ffadc7487cff6/Pillow-5.4.1-cp35-cp35m-win32.whl

100% | ██ | 1.7MB 351kB/s

Installing collected packages: Pillow

Successfully installed Pillow-5.4.1

You are using pip version 19.0.1, however version 19.0.2 is available.

You should consider upgrading via the 'python-m pip install-- upgrade pip' command.

C:\ Users\ andy\ sundyblog > python manage.py makemigrations

Migrations for 'blog':

0001_initial.py:

-Create model Article

-Create model Author

-Add field autor to article

C:\ Users\ andy\ sundyblog >

After reading the above, have you mastered the method of dealing with the entry-level error report of Python? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Method problem reason version processing content more upgrade helpless for this code again writing fields for this skills parentheses articles experience industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information OPPO Reno macOS Shulou Technology