Tag Archives: python3

fatal error: Python.h: No such file or directory

fatal error: Python.h: No such file or directory

Process: through PIP install a library, an error occurred and the python. H header file could not be found

Solution

Search stackoverflow. My environment is CentOS, so execute sudo Yum install python3 devel and then go to the PIP install library. It’s all OK

For apt (Ubuntu, Debian…):

sudo apt-get install python-dev   # for python2.x installs
sudo apt-get install python3-dev  # for python3.x installs

For yum (CentOS, RHEL…):

sudo yum install python-devel    # for python2.x installs
sudo yum install python3-devel   # for python3.x installs

For dnf (Fedora…):

sudo dnf install python2-devel  # for python2.x installs
sudo dnf install python3-devel  # for python3.x installs

For zippers (openSUSE):

sudo zypper in python-devel   # for python2.x installs
sudo zypper in python3-devel  # for python3.x installs

For apk (Alpine…):
This is a departure from the normal Alpine naming
scheme, which uses py2- and py3- prefixes

sudo apk add python2-dev  # for python2.x installs
sudo apk add python3-dev  # for python3.x installs

For apt-cyg (Cygwin…):

apt-cyg install python-devel   # for python2.x installs
apt-cyg install python3-devel  # for python3.x installs

Error report and flashback after packaging pynput into exe

Recently, after using the pynput library, the packaged exe flashback occurred.

Use pyinstall – f * *. Py to package, with terminal commands, so that you can see where the final error occurred.

We can see that the import reference is wrong.

The solution is:

        Reduce the version of pynput and use the old version. pip install pynput==1.6.8

 
 

Python3 Fatal error in launcher: Unable to create process using ‘”‘

Under windows, python2 and python3 coexist. When installing pyGame or other third-party libraries with PIP3, an error is reported as follows:

Fatal error in launcher: Unable to create process using '"'

resolvent:

C:\Users\Administrator>python3 -m pip install pygame

Reason: it needs to be used like this in Windows environment. I don’t understand the reason, and the Python – M instruction can’t find the exact meaning

There are also hints that it is a problem with the PIP version. Just update the pip to the latest version. The update command is “Python – M PIP install – upgrade PIP”.

Learning notes of Python 3: debugger speedups using Python not found

When you first run the PY module (eclipse), you usually encounter warning

warning: Debugger speedups using cython not found. Run '"C:\Python\Python36\python.exe" "C:\D\J2EESpace\eclipseNEON2\plugins\org.python.pydev.core_6.3.3.201805051638\pysrc\setup_cython.py" build_ext --inplace' to build.
pydev debugger: starting (pid: 10056)

The warning will not affect the running of the program. Indicates that cython was not found.

Python is an extension module tool of python, which is mixed with Python and C language to speed up the efficiency of Python.

According to the prompt, enter the “pysrc” directory and execute

python setup_cython.py build_ext --inplace

That’s it.

Note that “Microsoft Visual C + + 14.0 is required” error sometimes occurs during execution.

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Therefore, it is necessary to ensure that Microsoft Visual C + + 14.0 (download address) is installed on the PC.

Python 3 error typeerror: ‘dict’_ keys‘ object is not subscriptable

 

Problem: using in Python encoding dict.keys (), typeerror: ‘dict’ will be reported_ Keys’ object is not subscriptable

 

Solution: you need to use list in Python 3, as shown in the figure

 

Reason: Dict_ Keys ([‘No surfacing ‘,’flippers’]) returns a dict_ The keys object is no longer of the list type and does not support index

Therefore, the list type can be used

 

If there is any omission in my statement, please don’t hesitate to give me advice. Thank you very much!
If you think it’s useful, please praise it, creative power!

Solving attributeerror: module ‘urllib’ has no attribute ‘request’

Using urllib in Python 3 is an error like this:

Traceback (most recent call last):
  File "*.py", line 34, in <module>
    html_page = get(URL, req_header)
  File "*.py", line 18, in get_HTML
    request = urllib.request.Request(url, headers=req_header)
AttributeError: module 'urllib' has no attribute 'request'

An error code

import urllib
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Error reason:
in the Python AttributeError errors there are two kinds of main reason:
1.
2. File with same name exists in project directory

> port urllib.request <>ode>
>

import urllib
import urllib.request
request = urllib.request.Request(url, headers=req_header)
html = urllib.request.urlopen(request).read()
print (html)

Solving syntax error: unexpected character after line continuation character

SyntaxError: Unexpected Character After Line Continuation Character error occurred in the.py file executing on Windows command line.
The python installation path is
:



. The reason for this error is that python does not exit the interpreter, but instead executes in the interpreter environment. Py file.
Note: the.py file can only be executed in command line mode. If you do not exit, you are in interactive mode, where you enter a line of code and execute it. It is good to test a statement.
Type exit() to exit, and drag the.py file into the command line window to see the results (successful).

Install python’s C extension compilation environment under windows (solve “error: command’cl.exe’ failed: No such file or directory”)

Following a blog post, fixed in python2: Debugger speedups using cython not found.

The same problem was found in python3.5, where the original python required a VC++ Compiler for the installation (MInGW is also available, and it is generally not recommended to use PIP to install some third-party python libraries, and many extensions written in C required a VC++ Compiler for the installation, otherwise “error: command ‘cl.exe’ failed:” would occur. The most common compiler is Visual Studio C ++.

Compiler VS2008 C++ compiler is required in Python2.7, whereas python3 to 3.4 is compiled using VS2010, and python3.5 is compiled using VS2015.
However, as anyone who has ever installed a bloated IDE like VS knows, it comes bundled with a bunch of Microsoft plug-ins, takes up a lot of C disk space, and starts slowly.
if the computer is configured in a general way, the computer will be very stuck, and generally there is no need to install the entire VS.

For Python 2.7, Microsoft has released the Microsoft Visual C++ Compiler for Python 2.7 directly for download and installation.
http://www.microsoft.com/en-us/download/details.aspx?id=44266

For python3.5 you will need to install the Visual C++ Build Tools compiler provided by Microsoft
Download address: http://landinghub.visualstudio.com/visual-cpp-build-tools
to install, remember to choose Windows SDK 8.1 and 10 SDK, so don’t pack VS2015 can also compiled a package of C code in the PIP.

PY3 install box2d PY

direct PIP installation try

>>>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple box2d-py
...
 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

  ----------------------------------------
  Failed building wheel for box2d-py
  ...

we have to go to the wheel
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pybox2d

>>> pip install Box2D-2.3.2-cp36-cp36m-win_amd64.whl

tests the following code:

import gym
env = gym.make('CarRacing-v0')
env.reset()
for _ in range(1000):
    env.render()
    env.step(env.action_space.sample())


the atari wheel here
https://github.com/Kojoley/atari-py/releases

Install Python C extension compiler environment under windows (solve “error: command” cl.exe ‘ failed: No such file or directory”)

following a blog post resolved in python2: Debugger speedups using cython not found.

was found to have the same problem in python3.5. The original python required VC++ Compiler to compile and install (MInGW can also be used, is generally not recommended, is generally not recommended to use PIP to install some third-party python libraries under Windows, many use C to write some extensions, and need VC++ Compiler to compile and install, otherwise “error: The command ‘cl. Exe’ failed: “. The most common compiler for is Visual Studio C ++.

like Python2.7 requires VS2008 C++ compiler, whereas python3 to 3.4 is compiled in VS2010, and python3.5 is compiled in VS2015.

however, anyone who has ever installed VS this huge bloated IDE knows that it comes bundled with a bunch of Microsoft plug-ins, takes up a lot of C disk space, and starts slowly,
if the computer configuration is general, the computer will be very stuck, generally do not do related development, there is no need to install the whole VS.

for Python 2.7, the Microsoft Visual C++ Compiler for Python 2.7 is available for download and installation.
http://www.microsoft.com/en-us/download/details.aspx?id=44266

for python3.5 the compiler provided by Microsoft is installed – Visual C++ Build Tools

Download address:

http://landinghub.visualstudio.com/visual-cpp-build-tools
to install, remember to choose the Windows SDK 8.1 and Windows SDK 10 , so don’t pack VS2015 can also compiled a package of C code in the PIP.