Tag Archives: python

[Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed

1. Question.
Python3.8 environment
When using pip3 to install opencv-python, there is a
[modules/python3/CMakeFiles/opencv_python3.dir/__/src2/cv2.cpp.o] Error 1
recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all’ failed

2. Cause.
When compiling in opencv-python, it cannot call python3.8 properly
3. Solution:
sudo apt-get install python3.8-dev
4. Successful installation

[Solved] Python opencv imshow Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow

The result of error reporting is believed to be the same:

There is no Chinese in the path, but this error occurs. It feels very outrageous.

I couldn’t find the problem. Later, I wrote all the paths of the picture and found it\ F is a string formatting code. People are stupid, so friends write all the paths and find the problem.

This is the modified path:

In fact, when you see the formatting code, python will display it in another color, so I thought of it here! The path cannot be found until it is written!

Graphviz. Backend. Executablenotfound: failed to execute ‘dot’ Python uses graphviz to solve drawing errors

Solve the problem of drawing error with Python graphviz package

Finally, you need to restart pycharm to draw normally.

1. Error reporting

The error information is as follows:

graphviz.backend.ExecutableNotFound: failed to execute 'dot'make sure the Graphviz executables are on your systems' PATH

2. Determine variable type

The program prints variable data types plotted using graphviz

The print result shows that the type of drawing you want to draw is & lt; class ‘graphviz.dot.Digraph’>

3. Settle

3.1 Windows System Download and install graphviz

Graphviz download link to find the appropriate number of bits to download. Run the MSI file and install graphviz

3.2 configuring environment variables

Find the bin folder under the installation directory, copy the path, such as “D: \ software \ graphviz \ bin”, configure the system environment variable path, and create a new record for it. The content is the path copied in the previous step, as shown in Figure:

3.3 restart pycharm

After restart, use the. View () command to draw and display the image normally

. view() parameter explanation:
filename: picture name. The default is digraphv.gv. You can specify
Directory: picture saving path. The default is to save in the current path. You can specify

Run the code and view the image

Python import GDAL failed: DLL load failed. The specified module cannot be found.

Recently, after installing some libraries such as pyqt and labelme in CONDA environment, I planned to run a geotif to JPG program, but an error was reported at the beginning of running, showing that there was a problem with the sentence Import importlib. Machine in imp.py, and the last line
return_ Load (SPEC) importerror: DLL load failed: the specified module could not be found although import does not prompt syntax errors, it will report errors when running. It is speculated that there is a problem with the import of GDAL library. Because the GDAL installed before is available, it can not be used now. It took a long time to make trouble. Finally, it is directly reinstalled to solve the problem, which has nothing to do with the version
CONDA enters the environment,
PIP uninstall GDAL
then find the previous GDAL installation package. My GDAL is gdal-3.2.1-cp37-cp37m-win_ Amd64.whl, install this installation package directly
PIP install gdal-3.2.1-cp37-cp37m-win_ Amd64.whl
after successful installation, enter Python for import, and the problem is solved

[Mac M1] How to Solve import wordcloud Error: ModuleNotFoundError: No module named ‘wordcloud‘

My computer is a MacBook Pro M1 chip, which is the most difficult computer to configure. Ah, humble MAC people can cry every time.

I downloaded the wordcloud package in Anaconda and reported errors after import. I tried all the methods found in CSDN to deal with this error again. No one is successful, all kinds of problems. Later, I found a solution on the Internet, and the address is here: https://pypi.org/project/wordcloud/

In fact, it’s very simple. If you have tried PIP install on the terminal and failed, first enter Xcode select — install to ensure that you have downloaded this. If you have downloaded it like me, there will be

Just enter this
CONDA install – C CONDA forge wordcloud
to run it. When this appears, enter y

After running in the terminal, reopen your Spyder or pycham and re import wordcloud to stop reporting errors!

Python Error: Failed to establish a new connection: [Errno -2] Name or service not known

Error Messages:

Traceback (most recent call last):
File "/usr/local/python3/lib/python3.7/site-packages/ddt.py", line 192, in wrapper
return func(self, *args, **kwargs)
File "/usr/hxy/auto-test/interface/test_start.py", line 49, in test
result = RequestsHandle().httpRequest(method, reparam.uri, data=reparam.data, headers=reparam.headers)
File "/usr/hxy/auto-test/common/request_handle.py", line 32, in httpRequest
headers=headers, verify=False, proxies=proxies)
File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 542, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/python3/lib/python3.7/site-packages/requests/sessions.py", line 655, in send
r = adapter.send(request, **kwargs)
File "/usr/local/python3/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='sync-test.helianhealth.com', port=443): Max retries exceeded with url: /sync-channel/channel/admin/hsp/template/isOnline (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7fd369b643c8>: Failed to establish a new connection: [Errno -2] Name or service not known'))

I don’t get the error locally, but when I deploy the project on a Linux server, I get the error.
This is because there are other technicians using the server besides me, and the version of the request is outdated.
Solution: Update requests with the command: pip install -U requests

If the following error occurs.

ERROR: Cannot uninstall ‘requests’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
After installing a package with distutils, you need to uninstall it with distutils. Unfortunately distutils does not contain an uninstall command, so “uninstall using distutils” means that you have to remove the package manually.

cd /usr/lib/python2.7/site-packages/
mkdir /opt/pylib_backup/
mv requests* /opt/pylib_backup/

PIP list sees that the requests package has been unloaded

[root@bareos_server site-packages]# pip list |grep request
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
[root@bareos_server site-packages]# 

[Solved] Odrive gui Error: Do not use the development server in a productioun and supported version of the Socket

WARNING: Do not use the development server in a production environment. · Issue #446 · PaddlePaddle/VisualDL (github.com) https://github.com/PaddlePaddle/VisualDL/issues/446

The above is for reference

To set the parameters, then odrive_ The name of server depends on what the odrive GUI reports as an error, and it can be changed by comparison

set FLASK_APP=odrive_server
set FLASK_ENV=development

Then the version problem was solved by mistake

pip install --upgrade python-socketio==4.6.0

pip install --upgrade python-engineio==3.13.2

pip install --upgrade Flask-SocketIO==4.3.1

Solve the problem of raspberry pie using GStreamer. Importerror: cannot import name XXX introspection typelib not found

GStreamer is a video streaming framework. When it is first used after installation, an error will be reported when using the Hello World routine in the official doc, as follows:

ImportError: cannot import name GstRtspServer, introspection typelib not found


```python
#!/usr/bin/env python3
import sys

import gi

gi.require_version('GLib', '2.0')
gi.require_version('GObject', '2.0')
gi.require_version('Gst', '1.0')

from gi.repository import Gst, GObject, GLib

pipeline = None
bus = None
message = None

# initialize GStreamer
Gst.init(sys.argv[1:])

# build the pipeline
pipeline = Gst.parse_launch(
    "playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm"
)

# start playing
pipeline.set_state(Gst.State.PLAYING)

# wait until EOS or error
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(
    Gst.CLOCK_TIME_NONE,
    Gst.MessageType.ERROR | Gst.MessageType.EOS
)

# free resources
pipeline.set_state(Gst.State.NULL)

“209151;”

sudo apt-get install gir1.2-gst-rtsp-server-1.0