Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't import numpy after Anaconda installed

I just installed Anaconda 3.5. Terminal shows the correct version, and even has Continuum Analytics in brackets:

Python 3.5.0 |Continuum Analytics, Inc.| (default, Oct 20 2015, 14:39:26) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

However, when I type the following:

>>> import numpy

I get the error:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'numpy'

I know that Anaconda comes with numpy (I ran conda list, just to make sure). Anyone know what's going on?

It seems possible that my .bash_profile has something to do with it. If so, the contents follow.

# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

# added by Anaconda3 2.3.0 installer
export PATH="/Users/username/anaconda/bin:$PATH"

# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
like image 834
Jason Avatar asked Nov 19 '15 22:11

Jason


People also ask

Why is numpy not importing?

Python import numpy is not working that means eithers the module is not installed or the module is corrupted. To fix the corrupted module, uninstall it first then reinstall it.

How do I import numpy into Anaconda prompt?

If you installed the Anaconda distribution of Python, NumPy comes pre-installed and no further installation steps are necessary. If you use a version of Python from python.org or a version of Python that came with your operating system, the Anaconda Prompt and conda or pip can be used to install NumPy.

How do I know if numpy is installed on Anaconda?

Make sure you are using the Anaconda prompt, as the conda command only works in an Anaconda environment, and type conda list numpy . The result will show the version of numpy and associated packages.

Is numpy included in Anaconda?

If you don't have Python yet and want the simplest way to get started, we recommend you use the Anaconda Distribution - it includes Python, NumPy, and many other commonly used packages for scientific computing and data science.


1 Answers

I ended up uninstalling Anaconda and all versions of Python 3. After reinstalling Anaconda, numpy was available. Interestingly enough, on the version that works, Terminal shows the following information:

Python 3.5.0 |Anaconda 2.4.0 (x86_64)| (default, Oct 20 2015, 14:39:26) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

So apparently seeing "Continuum Analytics" does not mean that you're using Anaconda.

like image 50
Jason Avatar answered Sep 20 '22 09:09

Jason