2

I am fairly new to Python and am trying to install matplotlib and numpy onto the IDLE from python.org. I am using a Mac, and everything online tells me to use the command line to install using something like "pip install matplotlib" but the IDLE doesn't have any command line connected to it.

I have already managed to install pip but still am unable to import the modules I need from it. How can I do this?

MBP
  • 121
  • 1
  • 1
  • 4
  • 1
    you have to run `pip install 'whatever_module'` on your terminal, not on IDLE. once you've done that, you can just type `import 'whatever_module'` in IDLE to use that library. Keep in mind that IDLE is just [python REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop) and shouldn't really be used for actually writing full python scripts. – R Nar Aug 02 '16 at 20:29
  • @RNar I was able to install the modules with the terminal but I could only import them when using the Python built into the terminal. Any time I tried to import on the IDLE it said there was no such module – MBP Aug 02 '16 at 20:31
  • 1
    This may be caused by you having [multiple versions of Python on your computer](http://stackoverflow.com/a/25969007/5323213). Make sure that the python version IDLE is using and your terminal is using is the same. This is easily checked: when you open both of them, the first line should have the version number. – R Nar Aug 02 '16 at 20:36
  • You might want to use `pip3` instead of just `pip`, depending on how your Python is configured. – ash Aug 02 '16 at 20:48
  • To be honest, I would recommend jumping straight to just using anaconda here, because if you need numpy and matplotlib right now, you're probably going to need many of the other installed packages too. – Henry Prickett-Morgan Aug 03 '16 at 19:32

1 Answers1

0
from subprocess import call
call(['pip', 'install', 'MODULE'])
  • 3
    Welcome to StackOverflow! Although this might be a solution, consider supporting your answer with sufficient reasons and if necessary with useful links as to why this answer solves the OP's problem. – Rick M. Feb 26 '19 at 10:46
  • this does not work – notacorn Oct 19 '21 at 15:31