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

 

 

Similar Posts: