Importing libraries into Python

In this forum members can discuss topics about specific programming languages.
Post Reply
ArryMan
Posts: 3
Joined: Wed Oct 23, 2019 10:31 am

Importing libraries into Python

Post by ArryMan »

I have Python 3.7, running under Idle. I want to import nympy routines but the library isn't recognised. Math and Itertools etc are imported successfully.

I installed Anaconda on my machine, and everthing it has to offer, including nympy. I assumed it would sort out the path problems for me so that I could use the libraries outside of Anaconda, but it's not working. Any suggestions, please?
LilStalker
Posts: 74
Joined: Thu Nov 03, 2016 4:32 pm

Re: Importing libraries into Python

Post by LilStalker »

Do you mean numpy?
Image
ArryMan
Posts: 3
Joined: Wed Oct 23, 2019 10:31 am

Re: Importing libraries into Python

Post by ArryMan »

Yep! (must remember to wear specs when staring at computer screen . . .). But still get this error:
ModuleNotFoundError: No module named 'numpy'
LilStalker
Posts: 74
Joined: Thu Nov 03, 2016 4:32 pm

Re: Importing libraries into Python

Post by LilStalker »

And now you first have to download the library from the internet. Some libraries come immediately with Python download and some you need to download manually.
The easiest way to do it is to call:

"pip install numpy" in the command line.

If that doesnt work, google how to install numpy and you should find enough material on how to fix the problem.
Image
ArryMan
Posts: 3
Joined: Wed Oct 23, 2019 10:31 am

Re: Importing libraries into Python

Post by ArryMan »

Thanks, LilStalker. I tried that, and here is the script:

(base) DavidsiMac2854:~ davidellis$ pip install numpy
Requirement already satisfied: numpy in ./opt/anaconda3/lib/python3.7/site-packages (1.17.2)


As mentioned before, I hoped anaconda would take care of the path thing for me as I don't know how to do this. Somehow I have to let idle know where numpy is when I try to import it. The website didn't help on this.

Dave.
User avatar
DewayneGunter
Posts: 5
Joined: Tue Apr 21, 2020 9:32 pm

Re: Importing libraries into Python

Post by DewayneGunter »

How many versions of Python do you have installed? also, Anaconda if you use the Iron Python or Spyder IDE, I prefer Spyder. you should not have to point to where the library is located. I think you have more than 1 version installed and those libraries are only shown to 1 version, Spyder should take care of that. also, show the speed of execution without having to import a library in its profiler. and the ability to run scripts without saving. just for fast problem solving, messing around, and such. but if you prefer Idle. run cmd... pip install numpy (may have to run as administrator) but usually just windows key + r and in the run box type pip install numpy or pip3 install numpy
Post Reply