There is no library called Math

Asked

Viewed 1,185 times

2

Why when I care sqrt bookstore math He says there is no bookstore called math, but still the code works?

No error works well, but it is underlined in math and sqrt. To "heal" while I can’t find the answer I’m using cmath which would be for more complete numbers correct?

Why is it underlined that math does not exist and the code works the same?

  • To summarize for those who have the same problem: this was a specific error in a Pycharm update.

  • Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.

3 answers

5

If you use

import math

is providing the module math for your application to use. Then you need to call the function inside the module, so:

math.sqrt(9)

But if you use

from math import sqrt

Is bringing the function sqrt who is in math within the scope of your code. So the function is available right there and it doesn’t need, and it can’t, call from the original module, it’s like a function you wrote right there, like this:

sqrt(9)

I put in the Github for future reference.

Just be careful not to matter this way using the * not to pollute the namespace with all functions you probably won’t use. If you import some functions from the module, prefer the first one.

1

I found out just yesterday what happened, I care right and I know that I care but I must use Math.sqrt but what happened is that yesterday I had an update on pycharm which is my Idle and I discovered that there was an error in this att so what I did was install an older one to remedy that I already reported to pycharm dev, I found out because I went to the python Idle itself and there appeared such "error" thank you for answering anyway

0

Follow these steps in the pycharm:

1) Access: File> Settings.

2) In the side menu click on: Project: "Project Name" > Project Interpreter.

3) In the upper right-hand corner click on the gear and then on "Add local..."

4) In the window that will appear tick the options: "Inherit global site-Packages" and "Make available to all Projects" and click "OK", wait for loading.

5) Close Pycharm and open again and test!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.