Tag Archives: No module named XXX error

Django exception-ImportError: No module named django.core.management

Django error-ImportError: No module named django.core.managementProblem
description:
Enter manage.py runserver on the command line, it prompts that the django.core.management module cannot be found.

Problem analysis:
1. Make sure that Django has been installed, and check the Django installation directory. django.core.management does exist
. 2. There are two versions of Python on the computer. Check that the Python version set by the environment variable has Django installed
. 3. Followed by Command line input:
python
import django
django.VERSION
prints out Django version V1.3.1

4. Continue to point 3, type in the command line:
from django.core.management import execute_manager
command input is normal! ! ! This is weird. .

5. You can determine the function of normal Django, Python If you have heard that there may be multiple versions installed version compatibility issues, try to manually specify the version of Python to run Django project, at the command line:
Python25 manage.py the runserver
problem is solved

Solution :
specified before the command manage.py runserver to use Python version, at the command line:
Python25 manage.py runserver

Summary:
When there are multiple versions of Python installed on the computer, sometimes even if the version to be run is correctly set in the environment variable, there may still be errors. At this time, you can try to specify the Python to be used on the command line, such as python25 manage.py runserver

 

MAC OS Install opencv ModuleNotFoundError: No module named ‘cv2’

Opencv installed on Mac OS has installed Python 3.6

run the command brew install opencv3 after installation, an error was reported. But there is also a hint in pychar import CV2

Import CV2 runs with an error of “modulenotfoundererror: no module named ‘CV2′”. If the package of CV2 cannot be found, the installation of the expansion package can be executed: PIP3 install Python opencv PIP3

import cv2 print(cv2.__ version__) output opencv version number

installation complete

modulenotfounderror: no module named ‘cv2’ [How to Solve]

PIP install OpenCV Python
in Python, OpenCV reports an error. Importerror: no module named CV2 or modulenotfounderror: no module named ‘CV2’ is solved in this way. Because I forgot to install it when I was running TensorFlow, I recorded it. If pip is not installed, install PIP:

(1) Download PIP

Enter https://pypi.python.org/pypi/pip, download the second item

(2) decompression and installation

Unzip the downloaded file (only use unzip tools under windows, such as rar, and input tar – XF pip-9.0.1.tar.gz, or tar – XF file name at the terminal under Linux), enter the unzipped folder, call out the command line window or terminal, and input it under windows

python setup.py install

Input under Linux

sudo python setup.py install

After the installation is successful, enter

pip -v

Bpython ImportError: No module named _curses [How to Solve]

Python from the command line is actually very difficult to use. Recently, I wanted to try bpython, which has features such as syntax prompt and color highlight. As a result, after sudopipinstallbpython, I ran the prompt importerror: no module named_ curses

This is embarrassing. The curses library provides a terminal independent way to control the character screen. Curses is the standard part of most UNIX like systems (including linux ), and it has been ported to windows and other systems

1. The solution for windows is as follows

Installation package address http://www.lfd.uci.edu/~gohlke/pythonlibs/#curses

Install the corresponding package PIP install name.whl

Since my project is CentOS, the above solution is not applicable, so it is necessary to study the solution of Linux/CentOS

2. Solutions for Linux:

Use PIP (python2.7, if configure – with – insure PIP = yes, it will automatically help you install PIP) to install curses-2048 (sudo PIP install curses-2048) and continue to prompt

import curses
File “/usr/local/lib/python2.7/curses/__init__.py”, line 15, in <module>
from _curses import *
ImportError: No module named _curses

What is the reason?Why is curses installed

After careful analysis, you should find that the first time you did not install the cures module and after installation, the errors prompted are not exactly the same. When curses is not installed normally, you will be prompted that the module curses cannot be found. This time, you will be prompted no module named_ Curses, and prompts you to curses/__ init__. The error in the line of py. Actually, curves has been loaded, but there is an error in the middle of reloading

After comparing python2.6, we finally found that there was no corresponding curses Library in pythong2.7/lib-dynload

_ curses_ panel.so
_ curses.so

See the name, you may understand, originally_ Curses is this_ No doubt

Solution steps:

find/-iname "_curses*.so" 2>/dev/null
/usr/lib64/python2.6/lib-dynload/_curses.so
/usr/lib64/python2.6/lib-dynload/_curses_panel.so

find/2>/dev/null | grep 'python2.7/lib-dynload'|head -2 
/opt/soft/python-2.7.11/lib/python2.7/lib-dynload
/opt/soft/python-2.7.11/lib/python2.7/lib-dynload/math.so

cp /usr/lib64/python2.6/lib-dynload/_curses*.so /usr/local/lib/python2.7/lib-dynload/

find/-iname "_curses*.so" 2>/dev/null
/usr/lib64/python2.6/lib-dynload/_curses_panel.so
/usr/lib64/python2.6/lib-dynload/_curses.so
/usr/local/lib/python2.7/lib-dynload/_curses_panel.so
/usr/local/lib/python2.7/lib-dynload/_curses.so

bpython

That is, you copy these 2 so files from python2.6 to the lib-dynload folder of python2.7, and the problem is solved.

But, as to why pip install curses-2048 did not install these 2 so’s, it is not clear, but the problem is finally solved, and the specific reasons are subject to further analysis.

3. A pitfall under Ubuntu:

Under Ubuntu, copy the above two files from the included Python 3.5 to your own python 3.7 installation under /usr/local/lib/python3.7/lib-dynload, and make sure to change the version number in the name:

mv _curses.cpython-35m-x86_64-linux-gnu.so _curses.cpython-37m-x86_64-linux-gnu.so
mv _curses_panel.cpython-35m-x86_64-linux-gnu.so _curses_panel.cpython-37m-x86_64-linux-gnu.so

Otherwise, bpython will still report an error that the module was not found.

4. EOF occurred in violation of protocol

I frequently encounter the following error when using requests.

EOF occurred in violation of protocol (_ssl.c:600)

This error occurs on Python2 and Python3, macOS and Ubuntu. The error is related to the HTTPS handshake as seen in the error message.

This error is most fully discussed in this issue.

Through analysis, I found the cause of the problem: the security package was not properly installed when the requests library was installed.

Here is the solution (for Ubuntu): 1.

1. install the supported dev packages.

sudo apt-get install libffi-dev libssl-dev python-dev

If you do not install the above packages, you may get the following error when installing the support packages for requests.

distutils.errors.DistutilsError: Setup script exited with error: command ‘x86_64-linux-gnu-gcc’ failed with exit status 1
—————————————-
Failed cleaning build dir for cryptography</blockquote
2. install requests and its security support packages

pip install ‘requests[security]’

requests[security] is an extension that installs the following three additional packages to support secure connections.
pyOpenSSL

ndg-httpsclient

pyasn1

5、ImportError: No module named _sqlite3

find/-name _sqlite3.so 2>/dev/null
/usr/lib64/python2.6/lib-dynload/_sqlite3.so

find/-type d -name “lib-dynload” 2>/dev/null
/usr/lib64/python2.6/lib-dynload
/opt/soft/python-2.7.11/lib/python2.7/lib-dynload
/opt/soft/python3.6/lib/python3.6/lib-dynload

6. Microsoft Visual C++ Build Tools Download/Solve Visual C++ 14.0 is Required Issue

 

 

[Solved] Centos6: Python 2.6 upgrade to 3.7, error handling [no module named ‘_ctypes’]

Centos6 upgrade from Python 2.6 to 3.7, error handling [no module named ‘_ctypes’]

Because of the need of development, we upgrade Python 2 to Python 3 on CentOS 6 server. Due to the limitation of Intranet, manual installation is used here

1. View the current Python version

[python@VM000001564 ~]$ python -V
Python 2.6.6

2. Download Python stable version (current 3.7.2) from the official website for installation

Here, download software using Python User, install using root user

[python@VM000001564 ~]$ wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
[python@VM000001564 ~]$ tar -xzvf Python-3.7.2.tgz
[python@VM000001564 ~]$ cd Python-3.7.2


[root@VM000001564 Python-3.7.2]# ./configure
[root@VM000001564 Python-3.7.2]# make && make install

3. Post verification version after installation

[python@VM000001564 Python-3.7.2]$ python3 -V
Python 3.7.2

4. Set 3.7.2 as the default version

The default version is 2.6.6, and 3.7.2 needs to be set

[root@VM000001564 Python-3.7.2]# ls -al /usr/bin | grep python
-rwxr-xr-x.  1 root root      11232 Oct 16  2014 abrt-action-analyze-python
-rwxr-xr-x.  2 root root       9032 Jan 22  2014 python
lrwxrwxrwx.  1 root root          6 Oct 27  2014 python2 -> python
-rwxr-xr-x.  2 root root       9032 Jan 22  2014 python2.6

Back up the original Python soft link:

# mv /usr/bin/python /usr/bin/python.bak

links python to python3:

# ln -s /usr/local/bin/python3 /usr/bin/python

5. Problems encountered in installation

ModuleNotFoundError: No module named ‘_ ctypes’

Because version 3.7 uses external modules_ Ctypes, you need a new package libffi devel. After installing this package, you can install it again

yum install libffi-devel -y
make install

If you remove the file link dependency of Python under/usr/bin before the installation, then Yum can’t be used normally. You need to download the relevant software package to install. To save readers’ time, put the link

Download this version from CentOS 7

wget http://mirror.centos.org/centos/7/os/x86_64/Packages/libffi-devel-3.0.13-18.el7.x86_64.rpm
rpm -ivh libffi-devel-3.0.13-18.el7.x86_64.rpm

Download this version from CentOS 6

wget http://mirror.centos.org/centos/6/os/x86_64/Packages/libffi-devel-3.0.5-3.2.el6.x86_64.rpm
rpm -ivh  libffi-devel-3.0.5-3.2.el6.x86_64.rpm

after installing this package, recompile it again. Just follow the installation steps, and remember

Python.exe Error: No module named pip.__main__; ‘pip’ is a package and cannot be directly executed

WARNING: You are using pip version 19.2.3, however version 20.2.2 is available.
You should consider upgrading via the ‘python -m pip install –upgrade pip’ command.

Today I installed the mysql connection driver from the command line and found a warning that the pip version is too low.

Executed: python -m pip install –upgrade pip Resulting in the following error.

python.exe: No module named pip.__main__; ‘pip’ is a package and cannot be directly executed

Solution: python -m ensurepip

Perform again: python -m pip install –upgrade pip

upgrade success