Tag Archives: python

[Solved] ProxyError: Conda cannot proceed due to an error in your proxy configuration.

ProxyError: Conda cannot proceed due to an error in your proxy configuration.

0. Problem reporting error

conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch

The following errors are reported when installing pytorch:

ProxyError: Conda cannot proceed due to an error in your proxy configuration.
Check for typos and other configuration errors in any '.netrc' file in your home directory,
any environment variables ending in '_PROXY', and any other system-wide proxy
configuration settings.

The problem lies in agency

1. Solutions

(1) View current terminal agent

env | grep -i "_PROXY"

(2) Delete agents in turn

unset HTTP_PROXY
unset https_proxy
unset http_proxy
unset no_proxy
unset NO_PROXY

3. Whether the verification is successful

Enter again

env | grep -i "_PROXY"

then enter the following:
env. grep -i "PROXY"

[Solved] AttributeError: ‘PngImageFile‘ object has no attribute ‘imshow‘

How to solve error attributeerror:’pngimagefile’object has no attribute’imshow’ Successfully.


Error:

AttributeError: ‘PngImageFile’ object has no attribute ‘imshow’

Reasons:

Attribute error: the “pngimagefile” object does not have the attribute “imshow”

Solution:

Pngimagefile does not have imshow method, but has show method, so the following changes are required!

Modify
img.imshow()
to
img.show()

[Solved] error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor‘

Error Message:

error: (-215:Assertion failed) !_src.empty() in function ‘cv::cvtColor’

cv2.error: OpenCV(4.6.0) D:\a\opencv-python\opencv-python\opencv\modules\imgproc\src\color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cv::cvtColor'

Reason:

Path read error

Solution:

Original code

videos_src_path = "D:\pythonProject\python3.9\dataset\image\baozi_image\3.png"
frame = cv2.imread(videos_src_path)

Press the following to modify the read path

videos_src_path = "D:/pythonProject/python3.9/dataset/image/baozi_image/3.png"
#or  videos_src_path = r" D:\pythonProject\python3.9\dataset\image\baozi_image\3.png"
frame = cv2.imread(videos_src_path)

 

ERROR: Failed building wheel for osgeo [How to Solve]

ERROR: Failed building wheel for osgeo

Problem: When Installing pip3 install osgeo report an error: ERROR: Failed building wheel for osgeo

Solution:

Method 1

conda install gdal

Method 2:

1. According to the python version, download the corresponding GDAL installation file

for example: Python 3.8 download GDAL‑3.4.3‑cp38‑cp38‑win_amd64.whl

Cp38 stands for python3.8 version and windows64 bit

2. install:

pip3 install gdal-3.4.3-cp38-cp38-win_amd64.whl

 

[Solved] ERROR: Failed building wheel for pycryptodome

Error: failed building wheel for pycryptodome PIP installation error solution

1. Questions

PIP install pycryptodome build wheel error error error stack display reference OpenSSL error

 ERROR: Failed building wheel for pycryptodome

2. Solutions

# ①. install brew
# ②. install openssl@1
# ③ link to openssl
env LDFLAGS="-L$(brew --prefix openssl)/lib" CFLAGS="-I$(brew --prefix openssl)/include"

3. Other collected information

For devices using apple silicon, you can try this (because the default homebrew bin directory is different)

export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"

You can enter the view command yourself

brew info openssl

If you want to install an older version of cryptography (such as 2.9.x), you must link [email protected] instead of openssl@3

brew install openssl will prompt you to export

 

[Solved] wxauto error: ImportError: DLL load failed while importing win32gui: Can’t find the specified program

Background

Using wxauto to develop wechat robot, there was an error when running the program in Pycharm

Error prompt

Traceback (most recent call last):
  File "D:\Project\wechatBot\test.py", line 2, in <module>
    from wxauto import WeChat
  File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\__init__.py", line 2, in <module>
    from .wxauto import WxParam, WxUtils, WeChat, COPYDICT
  File "C:\Users\pokeu\anaconda3\envs\wechatbot\lib\site-packages\wxauto\wxauto.py", line 10, in <module>
    import win32gui, win32con
ImportError: DLL load failed while importing win32gui: Can't find the specified program.

Solution:

Check if the win32gui.pyd file exists in the C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\win32 directory

If not, run pip install pywin32 to install it.

Add C:\Users\username\anaconda3\envs\wechatbot\Lib\site-packages\pywin32_system32 to the system environment variable.

Notes.
a. User name Replace with your own user name.
b. The first half of C:\Users\username\anaconda3 is the installation path of anaconda, replace it with your own.
c. \envs\wechatbot is the path of the new environment I created (wechatbot), replace it with your own environment, or ignore it if you didn’t create it, and just find \Lib\site-packages\win32.

In the original import … import the following library before the original import …: import pywintypes, e.g.

import pywintypes
#import pythoncom # Uncomment this if some other DLL load will fail
from wxauto import WeChat
import time, random

Now run the program again, and there should be no error.

[Solved] weditor Plug-in Dump Hierarchy Error: Local server not started, start with $ python -m weditor

I had tried many solutions online. but they do not work. here is my working solution I found finally.

 

Solution:

1. First, make sure that ADB devices can query your device

2. Key solution: delete ATX on the mobile phone and re-execute python -m uiautomator2 init

3. Just in case, don’t directly execute the WebEditor. Be sure to execute python -m weditor

Then click Dump Hierarchy to synchronize the screen. Don’t use real-time, just use static.

[Solved] Pytorch Error: PytorchStreamReader failed reading zip archive failed finding central directory

Pytoch reports an error:

PytorchStreamReader failed reading zip archive: failed finding central directory

Error reporting position

An error is reported if the pre training model is not downloaded

resnet101 = torchvision.models.resnet101(pretrained=True)

Solution:

Delete the file C:\Users\Username/.cache\torch\hub\checkpoints.pth

[Solved] Pytorch Error: PytorchStreamReader failed reading zip archive failed finding central directory

Pytoch reports an error: pytochstreamreader failed reading zip archive: failed finding central directory

Error reporting position

An error is reported if the pre training model is not downloaded

resnet101 = torchvision.models.resnet101(pretrained=True)

Solution:

Download the files from the above URL and put them in the location of the path behind to replace the weights that have not been downloaded

[Solved] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection…

USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection: The devices connected to the system are not functioning.

When executing automated tests in python + selenium + pytest, I encountered the following error.

[25612:15512:0220/162104.300:ERROR:device_event_log_impl.cc(211)] [16:21:04.299] USB: usb_device_handle_win.cc:1049 Failed to read descriptor from node connection:
 The devices connected to the system are not functioning.(0x1F)

At present, the reason has not been found and can only be solved by violence:

Add the following options when starting chrome:

option = webdriver.chromeOptions()

# Prevent printing some useless logs
option.add_experimental_option("excludeSwitches", ['enable-automation', 'enable-logging'])
driver = webdriver.Chrome(chrome_options=option)

 

Supplement

For this statement

driver = webdriver.Chrome(chrome_options=option)

For chrome browsers, chrome_options=option, preferably written as options=option, that is:

driver = webdriver.Chrome(options=option)

Or you’ll see it in terminal

DeprecationWarning: use options instead of chrome_options
  driver = webdriver.Chrome(chrome_options=option)

[Solved] celery Startup Error: kombu.exceptions.VersionMismatch: Redis transport requires redis-py versions 3.2.0 or later. You have 2.10.6

Error when starting celery:

kombu.exceptions.VersionMismatch: Redis transport requires redis-py versions 3.2.0 or later. You have 2.10.6

The reason is that my redis version is too low and incompatible with kombu. But I won’t touch my redis
uninstall the current celery, download the 4.1.0 version of celery (kombu will be updated during installation), and then start it again. An error is reported:

pip install Celery==4.1.0
error:
KeyError: 'async'

The problem is that version 4.1.0 of celery is incompatible with python3.6.9, so replace it with version 4.1.1 of celery

pip install Celery==4.1.0

Start celery again:

celery -A celery_task.main worker -l info

Done!