Skip to content Skip to sidebar Skip to footer

Python Packages Are Imported On Terminal But Not On Idle

So I am new in Python. I downloaded Anaconda (and Homebrew) and using Terminal on my Mac I confirmed that, say, Numpy is installed: pip install numpy to get as a result Requiremen

Solution 1:

Since your IDLE is using Python 3 you should use

pip3 install numpy

to get it installed for the correct Python. If you want to use your default installed Python (2.x) instead, IDLE is located at /usr/bin/. From your terminal you can open it with

/usr/bin/idle

this should have the numpy you installed with pip install numpy

Solution 2:

See when you are working with Anaconda it creates its own virtual environment. Now, If you are new in python on MAC then you might not familiar with Virtual Environment.

I suggest you to download python from the official website www.python.org or Click here to directly download Python 3.6.2 on your MAC.

Then, Download Pycharm(The Best IDE for Python) Download the community version for beginner and it is also free.

Pycharm Community Version -> Click Here

And do whatever you want and also must read about Virtualenv

According to me, Pycharm is better then Anaconda's Jupyter Notebook

Wish you good luck and show your creativity in python ! !

Solution 3:

Erm... well it appears as though - since you have 2 versions on your computer - that it might be because it imported it into the other file path directory. Now, I've never worked with Mac, but I think if you just specify which pip you want to download from, it might work. For example, on Windows:

C:\Python34\Scripts\pip.exe install numpy

or if you were doing it for 3.6, you would follow the path to the folder, find pip and install. So, I suggest to install the normal IDLE before any other platform built upon it just because it is easier to import modules and is not as bad to break like yours has.

Solution 4:

There can be two issues -

  1. You are using python 2 as a kernel for IDLE, since numpy is installed for python3.6. This will raise an error.

  2. The issue is with anaconda's configuration with IDLE. Anaconda installs numpy in ./anaconda/lib/python3.6/site-packages. If IDLE uses systems default python instead of anaconda's. You will not be able to import numpy.

You can try running this snippet - import sys print('\n'.join(sys.path)) to track the location of python exactly.

One of the workaround that I can think of is - create a virtual environment using anaconda. Something like conda create -n py352 python=3.5.2 anaconda and then fire IDLE from your terminal. Though I am not entirely sure, if this works for mac. If it doesn't, let me know the output of - import sys print('\n'.join(sys.path))

Post a Comment for "Python Packages Are Imported On Terminal But Not On Idle"