Tag Archives: pycharm

Keyerror: “year not in index”

During learning, when writing Python code, the following error was reported: “keyerror” [‘year ‘] not in index “.

Problem description

When learning data visualization, the pandas package is called, and the code runs with an error. The error prompt is as follows

KeyError: "['year'] not in index"

Key error: ‘[‘year’] is not in index ‘

problem analysis

Check the code and find that the front and the back are inconsistent, and there are some problems when you write your own code

Solution
delete “1” and solve the problem

OK, keep learning.

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.

Solve the problem of red wavy line in pychar when importing module written by oneself

Solve the problem of red wavy line in the module imported from Pycharm
A red wavy line appears in the module imported by myself in Pycharm, as shown in the figure below. However, it can operate normally. The main problem is the file directory, and the module simply imported by import cannot find the path.

if you don’t feel comfortable with the red wavy line, you can also choose to solve this problem. The next two steps will be completed.
step 1:
enter Settings, go to the Python Console under the Console, check the option “Add source roots to PYTHONPAT”, and then click OK
. Step 2:
right click on the Directory and select Mark Directory as in the popup menu bar, then continue to select Sources Root, and you will immediately see the red wavy line in the code has been automatically removed.

Unable to call numpy in pychar, module notfounderror: no module named ‘numpy’

Python was installed before, and then Anaconda was installed because I was practicing using Python to write scientific calculations. However, after installing Anaconda, another problem occurred. When I wrote Python commands to call numpy on the command line, it could be used normally, but the call in PyCharm would report No module named ‘numpy’, that is, numpy could not be found, as shown below.
Numpy can be used normally on the command line:

However, numpy cannot be used properly in PyCharm:

This problem occurs because the interpreter that Pycharm USES is not the installed Python 3.6, but comes with the Python.exe interpreter, and there are only two modules PIP and SetupTools, so that many third-party libraries cannot be used in Pycharm. Only the Settings on PyCharm (File-> settings-> Project: Current project name -& GT; Set Interpreter in the Project Interpreter. Set it to Anaconda, as shown in the figure below.


Then the program will run normally

The experimental procedure for this example is as follows

from numpy import *
import operator

a = random.rand(4,4)
print(a)

Pychar runtime error r6034 solution

After Updating PyCharm, open a program, set the Project Interpreter and the software starts Updating Python Interpreter. It had run smoothly before, but this time it got stuck:

Simultaneously report an error:

 
Found a solution to this problem on Stack Overflow, so share it here. Click here for the original.
Step1: download Process Explorer and open procexp.exe inside.
Step2: select view-& gt from the menu of software interface; lower pane view -> Then find the Python. exe under the Pycharm directory and click, and the bottom pane should display a list of DLLs loaded for the application.

Step3: find “MSVCR??” in the DLL list. .DLL “, pay attention to the following path, as long as it is not under the path of “C:\Windows\WinSxS”, it should be deleted or renamed the suffix. For example, in the figure above, there is a MSvCR90. DLL under D:\Anaconda3\envs\ Python27 \msvcr90. DLL. Find it and rename it “MSvCR90. DLL -bak”.
Step4: restart pycharm and it will be ok.

Solutions to Django is not importable in this environment

Django is not importable in this environment.
(1) the first thing to illustrate the point, now on the network all kinds of copy, about today I encountered this problem, didn’t find a good way to online, and open a, then open a, completely identical copy, was no, really is too sad, to solve the problem it took me 4 to 5 hours (I am a rookie!
If this article does not obtain my consent, do not reprint and plagiarism!
(2) PyCharm downloaded from the Internet or copied from other computers cannot be opened directly, and some Settings need to be made, which is very annoying! Of course, the main problem is to set up the interpreter, but there are other problems, such as Django is not importable in this environment. My software version is python3.4.3 and django 2.0.7
(3) Solutions to this problem:
The file – & gt; Open, find your project file (project name), as follows, my project file is under the Learn folder, which has 4 projects

Then look at the following:
Select open in the new window to open a new window. Select another window to close the one you are currently open.

My entire project list is as follows:

It doesn’t matter that my project name is not the same as zaxt_tMP12 under the project.
And then: file – & gt; Settings – & gt; Project Interpreter

Then, look at the picture:

Hide interpreters that connect to other projects:

The effect is as follows, then green + :

If it’s OK, the result is like this (don’t follow it here, I’m just showing you!! :

Django is not importable in this environment if you don’t grab Inherit global site-packages, you will get an error when you run.



Very distressed! ?You’ve been messing with me for a long time. In fact, here’s what you should do:

Then, apply – & gt; ok

Django is out!!
(4) Finally, add an interpreter:

Select the interpreter we set up in the previous step! And run manager.py Runserver. Click Run again and you’re ready to run!

It took quite a while to write the document, redid it and liked it if it helped.
If this article does not obtain my consent, do not reprint and plagiarism!

“Failed to create interpreter” appears when pychar creates a new project

In creating the project, using the base(python=3.7) that comes with Anaconda can be created normally, but using my own environment (envs/python37/python=3.7), the following problem arises: D:\Program Files\JetBrains\Pycharm 2018.3.5\helper\packaging_tools.py list Error :Permission denied Command output

~ after nearly a week of torture, I also found some comments on Google, which is still a lot of resources on Google (portal). Generally speaking, it should be related to Anaconda’s own BUG, which is not compatible with Pycharm (maybe I have not found the relevant explanation yet)

here is my solution :

method 1 :

build environment by conda directly (not through Vartualenv to build virtual environment), managed by conda’s real environment as project environment, the disadvantages of doing so is that all use the same environment projects can see kit has no personalization is the same, and for any changes in the environment will have an effect on other projects, the safety factor is not high, but this method the effect is very good.

method 2 :

the environment is created in pythonw.exe, still using the virtual environment, but without Windows (the specific pythonw.exe difference is visible from the portal)

======================================2019-11-28_Edit_log=========================================

for the previous scheme can not solve the problem, I found a new method today, you can try

if you need

because the permission denial only occurs in python3’s Anaconda managed version so I’ll use this as an example of

is the same as before, the normal way of creating it, it will report an error

>

>

>

>

>

the steps are as follows :

1. Settings – & gt;

find project interpreter add location

2. Click to add the interpreter for python3, or if python3 does not have an interpreter, click show all to add the interpreter

3. Finally, click “apply ok”, and we can see the required version interpreter and virtual environment in the project

above is some of my experience summary, hope to be helpful to friends

Error server returns invalid timezone. Need to set ‘servertimezone’ property

idea connect to database error Server returns invalid timezone. Need to set ‘serverTimezone’ property


the reason is that the default time zone in MySQL driver is UTC, which is eight hours different from local time (China), so the link cannot be connected.

click on Set time zone

1. Fill in GMT in the box and save!
2. You can also add:?After the URL. serverTimezone=GMT

PS:
GMT (Greenwich Mean Time) : Greenwich Mean Time
UTC: world Standard Time
CST (China Standard Time) : China Standard Time

GMT + 8 = UTC + 8 = CST