Nathan majicvr.com
Nathan majicvr.com

Reputation: 1031

Numpy can't import even though conda says installed

Numpy somehow stopped working. I thought it might have been because I changed my $PATH env variable, but that doesn't really make sense. I did run source, then source .bashr and then source .bashrc and then source ~/.bashrc all in a row, so that might have something to do with it.

conda list | grep numpy

still returns reasonable things

Here is the error it prints when I try to import numpy

>>>import numpy as np

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'numpy'
Error in sys.excepthook:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
from apport.fileutils import likely_packaged, get_recent_crashes
File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
from apport.report import Report
File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
import apport.fileutils
File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
from apport.packaging_impl import impl as packaging
File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in <module>
import apt
File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
import apt_pkg
ModuleNotFoundError: No module named 'apt_pkg'

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

EDIT:

I have tried importing all the other packages I have since installed via Conda and none of them have worked either. They all seem to give similar errors (1. Error in sys.excepthook: and 2. No module named 'apt_pkg')

Upvotes: 2

Views: 1166

Answers (1)

whatsinthename
whatsinthename

Reputation: 2157

EDIT:

Big picture:

1) Uninstall conda first
2) Again install conda
3) Then install Anaconda from its official documentation.

Copy these commands:

conda install anaconda-clean
anaconda-clean --yes
rm -rf anaconda3/                 # uninstall

cd /tmp                           # install
curl -O https://repo.continuum.io/archive/Anaconda3-5.0.1-Linux-x86_64.sh
sha256sum Anaconda3-5.0.1-Linux-x86_64.sh
# verify legit shell file ^
bash Anaconda3-5.0.1-Linux-x86_64.sh
   # hit 'enter'
yes
source ~/.bashrc
conda install -c anaconda numpy   # install packages
conda install -c anaconda tensorflow

Note:

My system info: Ubuntu 16.04

Upvotes: 2

Related Questions