preamble
Recently, I've been using Pycharm, and I've been getting all sorts of errors while running or installing it, and I've already described how to fix the errors when installing pygame. The article summarizes most of the possible errors, including the causes and solutions.
(i) Pycharm error: No R interpreter defined
No R interpreter defined: Many R related features like completion, code checking and help won’t be available. You can set an interpreter under Preferences->Languages->R
Solution:
①Method 1: Download and install R, then add the path of R to Pycharm, (R language official website/CRAN/), and then add the path of R to pycharm after installation:
Files->Settings->Plugins->Languages & Frameworks->R Language
② Method 2: If you don't need R language, uninstall the R language plug-in directly:
Files->Settings->Plugins->R Language Support->Uninstall
(ii) The specified template could not be found: ImportError:DDL load failed while importing ft2font:
Solution:
File->settings->Project: your project name ->Python Interpreter
Find matplotlib on the right hand side and double click on it
Then select version 3.3.1, Install
Python Importing pyecharts module plotting times an error: "All chart types will be forced to use ChartItem for data item configuration starting with version v1.9.0" ofThe solution works as above, change the pyecharts version to 1.7.0 and you're done!
(iii) Pycharm does not recognize the import of self-written modules.
Sometimes a function module written by yourself in the same directory cannot be imported in another file in the same directory.
Solution:
(1) Open "file"->Settings to open the Python Console under Console, and check the option (Add source roots to PYTHONPAT).
(2) Right-click on your workspace (files/folders), click "Mark Directory as", and select Sources Root.
There is also a case where you write a function in a folder where there is no initialization function, i.e. __init__.py, just create a - a __init__.py in the folder, and the content can be written in nothing.
(D) pycharm cursor thick, can not edit the code
The cursor turns black because the input mode has changed to the rewrite mode, and INSERT can switch between insertion and rewrite modes.
Solution: Press the INSERT key on the keyboard. The location of the insert key may not be the same for different models, mine is a Lenovo Xiaoxin 14 inch, the insert key is on the lower right side of the keyboard, with PgDn on a key, to use insert you need to press Fn+Insert
(v) Using Pycharm to pass parameters to Python programs
If you need to enter parameters when the program is running, the program code in the following figure:
At this point the input parameters need to be run on the command line: python filename.py Parameter 1 Parameter 2
If you simply execute the "Run" command under the "Run" menu directly in the Pycharm environment, you will get an error saying that you need to enter parameters.
To be able to run it directly in Pycharm, you can set the parameters in the following way:
Run->Edit Configurations->Select the .py file where you want to set parameters->Parameters
Click OK to finish. Now it will run without errors!
pycharm Importing a project reports an errorno python interpreter configured for the project
Find Setup project interpreter and add the interpreter.
report an error:IndentationError:expected an indented block
Analysis:Indentation error!
Solution: In the line where the error occurs, just press Space or Tab (but not mixed) to indent. You have to indent where you need to indent, and if you don't indent, you'll get an error!
report an error:AttributeError: 'NoneType' object has no attribute 'shape'
Analysis:Mostly occurs in image processing problems
SOLUTION: After checking it was found that the image did not exist in python
report an error:error: (-215:Assertion failed) !() in function 'cv::resize'
Analysis:There is no image in that path, or the path does not exist. That is, cv reads 0byte of data
Solution:
① See if there is no path
② See if the picture in the path does not exist.
③ Even if the image exists, it is an error if it is 0 byte.
report an error:FileNotFoundError: [Errno 2] No such file or directory: 'data/'
Analysis:This is usually the folder of the current project files, and there are no files in the folder labeled after this one
Solution: Just add the file
Error: SyntaxError: invalid syntax
Analysis: English means "illegal statement". Missing punctuation (e.g., missing semicolons, missing & signs), multiple punctuation, misspellings, etc. can cause this kind of error.
Solution: check for spelling errors
report an error:RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 0
ANALYSIS: Using DataLoader to load images, some of these images have 3 channels (color images) while others may have a single channel (BW images), and since dim1 has different dimensions, it is not possible to join them into batches. Try adding img = ('RGB') to __getitem__ in the dataset
Solution: dataloader
def __getitem__(self,index): img_path=[index] label=[index] data=(img_path) # data = ('RGB') data=(data) return data,label
seleniumreport an error“: Message: 'geckodriver' executable needs to be in PATH.”
The reason for the error reported after running the field as shown in the figure isPlugins missing 'geckodriver' within paths
The solution is to download the appropriate version of the 'geckodriver' plugin and place it at the same path
As pictured:
summarize
This article on the causes and solutions of the most complete Pycharm error is introduced to this article, more related to the most complete Pycharm error solution content please search for my previous articles or continue to browse the following related articles I hope you will support me more in the future!