Tag Archives: pycharm

[Solved] Pycharm from xx import xx Error: Unresolved reference

There is a problem: the related classes cannot be referenced, but these classes are indeed in the project

Analysis reason: import failed because the path does not correspond. Pycharm defaults to the source directory as the root directory of the project

Solution:

Search the corresponding item searchtest and select “sources”; Finally, be sure to “apply”

Set the folder where the package is placed as source, so that the module class of import can be found through these source folders as the root path, that is, find the imported things in these source folders

Or

[Solved] forrtl: error (200): program aborting due to control-C event

forrtl: error (200): program aborting due to control-C event
pycharm Error:
forrtl: error (200): program aborting due to control-C event
Image PC Routine Line Source
libifcoremd.dll 00007FFD5FCA3B58 Unknown Unknown Unknown
KERNELBASE.dll 00007FFDC015B933 Unknown Unknown Unknown
KERNEL32.DLL 00007FFDC15D7034 Unknown Unknown Unknown
ntdll.dll 00007FFDC2762651 Unknown Unknown Unknown

Solution:

pip install --upgrade scipy

Just run this in terminal. The principle is not clear.

ERROR: GLEW initalization error: Missing GL version

System: Ubuntu 18.04
since there is no NVIDIA XXX folder in my/usr/lib directory, use the following method in the. Bashrc file:

export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-460/libGL.so

it won ‘t work.

The final solution is:

By manually adding environment variables for the current running environment, run – & gt; Edit configuration – & gt; Add the corresponding environment variable to the environment variable

Variable name: LD_ Preload
variable value:/usr/lib/x86_ 64-linux-gnu/libGLEW.so

Solution to [SSL: certificate_verify_failed] when you get downloads video

[SSL: certificate_verify_failed] problem when downloading video using you get and ffmpeg

Since the you get -- debug debugging shows that it is a certificate verification problem, the part ignoring SSL certificate verification is added to the code and implemented in pycharm (non command line)
Modify url = 'website', output_Dir = R 'save path'

import ssl
from you_get import common

# Ignore certificate validation issues
ssl._create_default_https_context = ssl._create_unverified_context

# Call any_download_playlist in you_get.common to download a collection
common.any_download_playlist(url='https://www.bilibili.com/video/BVXXX',stream_id='',info_only=False,
                             output_dir=r'F:\StudyLesson\YouGet',merge=True)

# Call any_download in you_get.common for single set download
common.any_download(url='https://www.bilibili.com/video/BVXXX?p=8',stream_id='',
                    info_only=False,output_dir=r'F:\StudyLesson\YouGet',merge=True)

So far, the video has been downloaded successfully
record.

Error = 2, no such file or director is prompted in the lower left corner of the MAC pycharm running file

Background:
System: MAC system
problem: Python runs the python project provided by others, but the file in the project exists, but it prompts that there is no such file
specific error:
error: cannot run program “/ users/Bob/pychamprojects/untitled/venv/bin/Python” (in directory “/ users/Bob/desktop/1”): error = 2, no such file or director

Solution:
delete the hidden. Idea file under the project, restart pycharm and run it again

Syntaxerror: unexpected EOF while parsing solution and ideas

Online learning code, error reporting

SyntaxError: unexpected EOF while parsing

If you encounter this problem, first check whether the parentheses are written less

View source code

res = sorted(res.iteritems(), key=lambda x : x[1])

The code is the version of python2. X. res.iteritems () has been dropped under python3. X, so it is modified to

res = sorted(res.items(), key=lambda x : x[1])

Import error, failed to import the debug version of PYD

Today, I used swig to encapsulate the underlying C + + library. After the result was encapsulated, release was OK. However, in the debug mode, the import failed all the time, indicating that the module could not be found. Why did I fail when I had PYD?

After troubleshooting, PYD in the original debug mode must be added_ d

The result is to add_ D is solved; For example_ Somelib.pyd should be_ someLib_ d. PYD, so Python can import.

Modify cmakelists.txt to ensure that it is added in debug mode_ d

set(CMAKE_DEBUG_POSTFIX _d)
set_target_properties(${target_name} PROPERTIES DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

[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 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]# 

The python script tool of ArcGIS reports an error: indentationerror: unexpected indent solution

Background

At the beginning, I wrote an ArcGIS Python script, which is an independent script. I ran it in Python and ran it successfully. But if you put this script in the ArcGIS toolbox, it won’t work properly. The following errors are reported.

IndentationError: unexpected indent。

  The above figure is an article from Baidu experience. Because there was no screenshot at that time, I didn’t bother to reproduce this problem again…

Find solutions

Code indentation problem

When searching for this error report on Baidu, most of the answers are to ask you to find the indentation problem and space problem in the code. As in the article from the above figure.

The problem is that my code can run successfully in pycharm, and I checked the code several times and found no problem…

Chinese in code (including Chinese in notes)

I use ArcGIS 10.2 and python version is 2.7. This version of Python doesn’t support Chinese very much, but generally you can run normally by adding # coding = UTF-8 at the beginning of the code in the python environment.

# coding=utf-8

There is a Chinese comment on the last line of the wrong line of my code. So I tried to remove that line of Chinese notes and succeeded

Summary

1. If the python script of ArcGIS does not need Chinese, do not use Chinese

2. If you have to use Chinese, you can consider adding # coding: cp936 at the beginning of the script code