Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The processing method of entry-level error reporting in Python

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report