[Python] A workaround based on common errors and my past experience

ImportError: No module named

There is no such module

error.py


ImportError: No module named pandaas

Most of them are simply misspelled.

list index out of range

List reference is out of range

error.py


IndexError: list index out of range

For example, when turning with a for statement, if the nth does not exist, but it has been processed, an error outside the range often occurs. Personally, I have a lot of impressions when I turn it with for and delete it.

NameError: name 'XXX' is not defined

The variable XXX is undefined

error.py


NameError: name 'XXX' is not defined

Personally, I often get this error when I create a variable called test, try it, and try to process it in production. Basically, the variables are not defined, so if you suspect a spelling mistake, you can avoid it immediately.

TypeError: 'XXX' object is not iterable

The type XXX cannot be repeated.

error.py


TypeError: 'int' object is not iterable

This is an error that occurs in the for syntax. Originally, it occurs by turning a type that cannot be repeated with the for syntax.

For example, integer type and decimal type cannot be processed repeatedly with the for syntax. It is necessary to convert it to the character type (str) once and process it repeatedly.

I will add it as needed.

Recommended Posts

[Python] A workaround based on common errors and my past experience
A memo with Python2.7 and Python3 on CentOS
Create a decent shell and python environment on Windows
A memorandum of stumbling on my personal HEROKU & Python (Flask)
Building a Python environment on a Mac and using Jupyter lab
Python on Ruby and angry Ruby on Python
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a game leaderboard on Alibaba cloud using Python and Redis
Build a Python environment on your Mac with Anaconda and PyCharm
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
A python script that deletes ._DS_Store and ._ * files created on Mac
docker build python based on alpine
Building a Python environment on Mac
Python a + = b and a = a + b are different
Python 3.6 on Windows ... and to Xamarin.
Building a Python environment on Ubuntu
Summary and common errors about cron
Create a Python environment on Mac (2017/4)
Integrate Modelica and Python on Windows
Create a python environment on centos
[Python] return A [or / and] B
Build a python3 environment on CentOS7
Deploy a Python app on Google App Engine and integrate it with GitHub
A story about my new study of Python after 3 years of MATLAB experience
[Python] Create a linebot to write a name and age on an image
Create a Python3 environment with pyenv on Mac and display a NetworkX graph
I want to format and check Python code to my liking on VS Code