Tag Archives: pycharm

Pycharm Connect MySQL to Find Sheet Error: RuntimeError: ‘cryptography’ package is required for sha256_password or caching_sha2_password auth methods

When linking MySQL database through pycharm, the query report will give an error prompt:

RuntimeError: ‘cryptography’ package is required for sha256_password or caching_sha2_password auth methods

Method 1: restart MySQL

① As an administrator, enter the command line “net start MySQL 80” in CMD (the service name of MySQL 80 is different here according to the installed version) to start mysql

② Enter “MySQL” to enter mysql.

③ pycharm runs again without reporting an error.

Method 2: install the cryptography package

Error: runtimeerror: ‘cryptography’ package is required for sha256_ password or caching_ sha2_ password auth methods

The error message means: sha256_Password and caching_sha2_ Password two encryption methods require cryptography.

Therefore, you only need to install the cryptography package: PIP install cryptography

① First, if you see mysql running in task manager.

② After opening cmd, enter the command "pip install cryptography", after successful installation, run pycharm again, no error is reported.

[Solved] Pychart Install a Third-part Library error: no such option: — bulid dir

Error content: no such option: — bulid dir

pycharm relies on -- build dir to install third-party libraries. This flag has been removed since the version of 20.2.

Solution:

1. Switch the version of PIP: Python - M PIP install PIP == 20.2.4 #### switch the version of PIP

2. Update pychart: click Help -> check for updates in pychart

[Solved] Pycharm Build a flash environment Error: Non zero exit code (2)

Error during installation

Analyze problems

Pycharm relies on — build dir to install packages, but this has been removed in the latest version of PIP

The PIP I use now is version 21.3.1. The solution is to reduce the PIP version of the project to PIP 21.2.4

Specific operation

1. Run CMD or windows PowerShell as administrator

2. Enter the interpreter path under the file + – M PIP install PIP = = 21.2.4

3. Open pycharm and view PIP information in project interpreter

4. Now try downloading flash

5. You should be able to display success and create a py file

6. Run it and the following web address will appear. Click to open

7. When the content appears, flash is successfully installed

How to Solve graphviz run Error in Pychart

Problem: after installing graphviz, it runs normally on the command line (Python runs normally, PDF can be output normally, pop up jump to view graphics), but documents cannot be output normally on pychart and notbook.

And an error will appear in pychar:

ExecutableNotFound: failed to execute [‘dot’], make sure the Graphviz executables are on your systems’ PATH

Solution:

Add the following two new variables to the system environment variable:

GRAPHVIZ_ DOT

GRAPHVIZ_ INSTALL_ DIR

The values are bot.exe address and graphviz root directory respectively

[Solved] Pycharm Error: TypeError: init() missing 1 required positional argument: ‘on_delete’

TypeError: init() missing 1 required positional argument: ‘on_ delete’

After Django 2.0, you need to add on when defining foreign keys and one-to-one relationships_delete option. This parameter is used to avoid data inconsistency between the two tables, otherwise an error will be reported:

Original: user=models.OneToOneField(User)
Now: user=models.OneToOneField(User,on_delete=models.CASCADE) The original (models.CASCADE) exists by default

on_delete includes cascade, protect and set_NULL, SET_Default and set() are five selectable values

CASCADE:This value is set to cascade delete. PROTECT: This value is set to report an integrity error. SET_NULL: This value is set to set the foreign key to null, provided it is allowed to be null. SET_DEFAULT: This value is set to set as the default value of the foreign key. SET(): This value is set to call the outside value, which can be a function. CASCADE is used in general.

After Django 2.0, the editing mode in include will be changed

Change: url(r'^student/', include('student.ursl', namespace="student"))
to:url(r'^student/', include(('student.ursl',"student"), namespace="student"))

[Solved] Pycharm Error: Error: failed to send plot to http://127.0.0.1:63342

pycharm error: Error: failed to send plot to http://127.0.0.1:63342
pycharm error: Error: failed to send plot to http://127.0.0.1:63342

#Machine learning using numpy implementation
import numpy as  np
from matplotlib import pyplot as plt
#Generate the input data x as well as the objective function y. Set the random number seed to allow for multiple methods of comparison
np.random.seed(100)
x=np.linspace(-1,1,100).reshape(100,1)
y=3*np.power(x,2)+2+0.2*np.random.rand(x.size).reshape(100,1)
#Drawings
plt.scatter(x,y)
plt.show()

 

Solution:

Go directly to pycharm setting – > tools——> Python scientific, then uncheck ☑ Show plot in tool windosw.

Solve the problem of pychart connecting MySQL 1366 and reporting an error

If you use pymysql to connect to MySQL, an error 1366 will be reported

engine=create_engine('mysql+pymysql://root:1234@localhost/b',#Specify the database engine to connect to, e.g. MySQL, Oracle, etc.
                     encoding='utf-8',
                     echo=False)

Error reporting:

E:\Anacoda\lib\site-packages\pymysql\cursors.py:170: Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 497")
  result = self._query(query)

Solution

Download MySQL connector Python from the official MySQL website: https://dev.mysql.com/downloads/connector/python/

After downloading and installing, change pymysql in the original connection code to mysqlconnector

engine=create_engine('mysql+mysqlconnector://root:1234@localhost/b',
                     encoding='utf-8',
                     echo=False)

 

Error when using input in pycharm

In python2, you can’t directly use input to obtain strings. You need to use raw_Input() , so the error may be the wrong version of Python and the wrong statement

Adjusting Python version in

pycharm:

  file–setting–project–project interpreter

Error reported by python console in Pycharm [How to Solve]

Error:Error:Cannot run program “E:\PythonProjects\venv\Scripts\python.exe” (in directory “E:\ProjectsHttpR”): CreateProcess error=2, system could not find the specified file.

Solution:

1 file–setting–Project: project name–Project Interpreter–path select the python installation path.

2 file–setting–Buile,Execution,Depolyment–Console–Python Console–Python interpretr. path Select the installation path of python.