Tag Archives: python

Solution of running error reporting attributeerror: ‘rectangle’ object has no property ‘normalized’

Have a problem

When running the code, the following error prompt appears:

AttributeError:'Rectangle' object has no property 'normed'

resolvent

The reason is that the library has been updated and there is no such attribute. Delete the normal in the code (no error, but it seems that it can’t be drawn)

Replace the normal attribute in the code with density , and add an attribute stacked = true .


Thank you for your comments.

The solution of the error code is 2503 in Python installation


Copyright notice

Original author: brother Gu’s younger brother author blog address: http://blog.csdn.net/lfdfhl


Problem description

When installing Python 3.7.2 in win10 device, an error is reported: the error code is 2503, as shown in the figure below:

Solution

Just modify the permissions of the folder C: Windows: temp.

The first step: find the folder C: Windows: temp

Step 2: open the temp folder and edit its permissions

Step 3: change its permissions to full control

numpy.random.rand()

numpy.random.randn (d0, d1, … , DN) is to return one or more sample values from the standard normal distribution.  
numpy.random.rand (d0, d1, … , DN) in [0,1].   

 

numpy.random.rand (d0,d1,… ,dn)

The rand function generates data between [0,1] according to the given dimension, including 0 and excluding 1DN table. The return value of each dimension is the array of the specified dimension

np.random.rand(4,2)
array([[0.64959905, 0.14584702],
       [0.56862369, 0.5992007 ],
       [0.42512475, 0.83075541],
       [0.75685279, 0.00910825]])

np.random.rand(4,3,2) # shape: 4*3*2
array([[[0.07304796, 0.48810928],
        [0.59523586, 0.83281804],
        [0.47530734, 0.50402275]],

       [[0.63153869, 0.19636159],
        [0.93727986, 0.13564719],
        [0.11122609, 0.59646316]],

       [[0.17276155, 0.66621767],
        [0.81926792, 0.28781293],
        [0.20228714, 0.72412133]],

       [[0.29365696, 0.53956076],
        [0.19105394, 0.47044441],
        [0.85930046, 0.3867359 ]]])

 

Python data analysis dataframe converts dates to weeks

When doing data analysis with Python, how to add a new column of weeks “week” and change the date, such as “2021-03-02” to the nth week of 2021?

Introduce two methods:
the dataframe of my data is called sample, which has the feature “date”. Now add a new feature “week”
1 dt.week

sample["week"]=sample["date"].dt.week

2. Use datetimeindex

df['week'] = pd.DatetimeIndex(sample['date']).week

Error: enoent: no such file or directory, stat

The gitbook project can’t run when you open it on another computer. Both gitbook serve and gitbook build report errors.

Error: ENOENT: no such file or directory, stat ‘C:\Users\Lenovo\www\mdspg\md\mybook_ book\gitbook\gitbook-plugin-fontsettings\ fontsettings.js ’

it turned out to be a bug (vision: 3.2.3).

The solution is as follows.

The following file was found in the user directory.
.gitbook\versions\3.2.3\lib\output\website\ copyPluginAssets.js

Replace all

confirm: true

with

confirm: false

Python error memoryerror

Python error memoryerror

Python 32bit can only use 2G of memory at most. If the memory is larger than 2G, memoryerror will be reported.

However, 64bit Python has no such limitation, so it is recommended to use 64bit python.
Possible problems: in the past, official libraries of numpy and SciPy only supported 32bit python, but now we should release the corresponding 64bit version.

Postman error: connect econrefused 127.0.0.1:7890

Problem Description: check the consle and find that postman has been crazy to link to the local port 7890, but I didn’t use the port at all. Could not send request has been reported wrong.

Solution: 1. I install postman on one computer, and then link to the same service port. Check the consle and find that the local port 7890 is not connected. Compare the two settings and find that they are the same.

2. But I always think it’s a setting problem. Later, I kept trying to find that I could just remove the check of setting proxy use the system proxy

 

I guess the local proxy settings of the pot.

Python reported an error with keyerror: ‘longitude’

The error reporting interface of Python is shown in the following figure:
. I found a solution on the Internet, which may be useful to you. But I tried it, but it didn’t work. So when I looked at it, I found that it was caused by my carelessness. Ah, as shown in the figure below, there is a comma missing in front of longitude, as shown in the figure below:
, so this problem is solved. OK, I will continue my course design.

An error keyerror255 was reported when pymysql connect to MySQL

Contents of articles

Solutions for error reporting

abstract

Pymysql connect to MySQL reported an error of keyerror255. Recently, I was trapped for more than two months by a difficult problem. If you search this title, you can see that the search engine has provided n ^ 2 articles on solutions. Why do you still trap me for so long?Don’t I know Baidu?NO NO NO!! The biggest problem is that my executive computer and data storage computer are not the same computer!!

Error information

  File "D:\Programfiles\Anaconda3\lib\site-packages\pymysql\connections.py", line 1269, in _get_server_information
    self.server_charset = charset_by_id(lang).name
  File "D:\Programfiles\Anaconda3\lib\site-packages\pymysql\charset.py", line 38, in by_id
    return self._by_id[id]
KeyError: 255

The main reason is that MySQL 8.0 updates many character sets, but these character sets are longer than 255 , so the old version of pymysql does not support characters longer than 255

Online can find a lot of articles to solve this problem, consistent solution, update pymysql

pip install --upgrade pymysql

The following casually put a, interested can see, don't look also doesn't matter, full text summary on a sentence update pymysql, directly execute the above update code, if solve, OK! All is well, you can quit, but you can't solve it. The link article is not meaningful. Let's continue to read my text

Django appears after changing the default database SQLite3 to pymsql Keyerror:255 How to upgrade pymysql

Solution

As mentioned before, my executive computer and data storage computer are not the same computer!!
My own computer is mysql5.7, and the data storage computer version is 8.1
because at the beginning, the company's network security was upgraded to a secondary level, and then the company's intranet VPN was updated once (big exchange, the interface is different),
so at the beginning, I thought it was caused by the network security policy,
after all, all the online updates are pymysql, I'm already up-to-date and can't update any more

In fact, the solution is in a word, too lazy to beat around the bush so many words

uninstall and reload MySQL

yes! You're right! Is the MySQL database to unload, and then re install a version of 8.0 and above

So the main reason is that at the beginning MySQL 8.0 has updated many character sets, but the length of these character sets exceeds 255


Write in the last canvassing session
recently participated in the CSDN official organization of "geek +" original blogger competition
after many screening, finally on the top 50
original is not easy, help cast a free vote
support: Click to vote
thank you!!!