LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-10-2016, 08:52 AM   #1
chris_crunch
Member
 
Registered: Jan 2016
Location: Braintree, Essex
Distribution: Ubuntu 14.04
Posts: 107

Rep: Reputation: Disabled
Python numpy error


In Python, when I try...

Code:
>>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/chris/anaconda2/lib/python2.7/site-packages/numpy/__init__.py", line 175, in <module>
    from .version import git_revision as __git_revision__
ImportError: No module named version
>>>
Hmm? I mean, I have python-numpy installed

Code:
chris@chris-crunch:~/apps/caffe-master$ sudo apt install python-numpy
[sudo] password for chris: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python-numpy is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 15 not to upgrade.
So does this mean the file path is wrong or something?
 
Old 02-10-2016, 09:00 AM   #2
chris_crunch
Member
 
Registered: Jan 2016
Location: Braintree, Essex
Distribution: Ubuntu 14.04
Posts: 107

Original Poster
Rep: Reputation: Disabled
I think I made it worse...

Code:
 chris@chris-crunch:~/anaconda2/lib/python2.7/site-packages$ rm -rf numpy
Code:
 >>> import numpy as np
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
I have googled and scrolled through many pages to try and find an answer to this. But all such attempts have failed...

Python 2.7.11 :: Anaconda 2.4.1 (64-bit)

Last edited by chris_crunch; 02-10-2016 at 09:53 AM.
 
Old 02-10-2016, 10:25 AM   #3
153rd
Member
 
Registered: Mar 2015
Location: The Netherlands
Distribution: CentOS 7, Ubuntu 12.04, Linux-Mint 17.3
Posts: 46

Rep: Reputation: Disabled
Hey,

Try to reinstall python [sudo apt-get remove/uninstall] and then [sudo apt-get install] ..).
You can see if the system can find the library by calling [python --version], or [which python] in the CLI.

What did you do to make it worse?

You can confirm if your path is set right by doing [echo $PATH] in the CLI.

Cheers!

Last edited by 153rd; 02-10-2016 at 10:27 AM. Reason: Increased readability - added info
 
Old 02-10-2016, 10:41 AM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,769

Rep: Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052
I wonder if you installed the correct version for the python interpreter you are trying to use?

On my system I have the following options:
Code:
$ pacman -Ss python2?-numpy
extra/python-numpy 1.10.4-1
    Scientific tools for Python
extra/python2-numpy 1.10.4-1
    Scientific tools for Python
I would need to install the second version with the 2 in it if I were to use python 2.X and if I installed the first version it would be for python 3.X

So you might have to confirm either which version you have installed or which version of the python interpreter you are using to run your script?
 
Old 02-11-2016, 04:20 AM   #5
chris_crunch
Member
 
Registered: Jan 2016
Location: Braintree, Essex
Distribution: Ubuntu 14.04
Posts: 107

Original Poster
Rep: Reputation: Disabled
I think I worked out the problem.
I was using anaconda2 as my version of python.

This seems like a better idea to me, as if I'm messing around using commands like
Code:
conda install bleh
and something goes terribly wrong, it's separate from linux right?

And it did break actually. My mentor was looking at it today. He said "something ate conda" as the conda command didn't exist anymore. lol.

Okay so I'm trying to uninstall and reinstall Anaconda following the instructions on their website. Once I uninstalled it, the normal version of python was able to import numpy. So let's try with conda...

Okay guys conda is installed again. But I'm still using the default python. Does anyone know how I can change this so it uses the conda version? something like pythonpath variable?

Last edited by chris_crunch; 02-11-2016 at 04:47 AM.
 
Old 02-11-2016, 04:56 AM   #6
chris_crunch
Member
 
Registered: Jan 2016
Location: Braintree, Essex
Distribution: Ubuntu 14.04
Posts: 107

Original Poster
Rep: Reputation: Disabled
As in, I think it's here:

Code:
/home/chris/anaconda2/lib/python2.7
But I don't even know how to run python from here? Like I don't really know what I'm doing when I type in to the command line:

Code:
chris@chris-crunch:~$ python
Python 2.7.6 (default, Jun 22 2015, 17:58:13) 
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
Which is making this hard to google... Is this called launching a python interpreter or something?

EDIT: Okay, I think I've fixed it.
By doing this

Code:
conda create -n py27 python=2.7 anaconda
Then some stuff happenened.

I don't understand this:

Code:
 # To activate this environment, use:
# $ source activate py27
#
# To deactivate this environment, use:
# $ source deactivate
#
But now this works!
Code:
 chris@chris-crunch:~$ python
Python 2.7.11 |Anaconda 2.5.0 (64-bit)| (default, Dec  6 2015, 18:08:32) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
Yay. Um, so my problem has been fixed by luck and internet scrolling. But if anyone could shed some light on what I actually did, I'd appreciate it. Thanks.

Last edited by chris_crunch; 02-11-2016 at 05:02 AM.
 
Old 02-11-2016, 05:03 AM   #7
153rd
Member
 
Registered: Mar 2015
Location: The Netherlands
Distribution: CentOS 7, Ubuntu 12.04, Linux-Mint 17.3
Posts: 46

Rep: Reputation: Disabled
When you type "python", you basically tell your OS to look for the "python" program in the folders pointed to by your PATH - variable.
(I'm not experienced enough to give a more exact description)

Same as you use "grep", "ls", "man", etc. These are all binaries that exist in your /etc/bin folder for example.

So if you use "which python", you will get a directory of the python program that will be called if you type "python".
Confirm first that
Code:
/home/chris/anaconda2/lib/python2.7
is in fact the python library that's being called.

Last edited by 153rd; 02-11-2016 at 05:04 AM. Reason: correct insertion of code tags
 
Old 02-11-2016, 08:13 AM   #8
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,769

Rep: Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052
You have mentioned a mentor, which would lead me to guess you are taking a course ... is there any reason you have not asked your teacher or mentor these questions?

In future you may want to alter your questions to advise that you are using anaconda instead of standard python otherwise you will receive answers (like my first one) that are irrelevant.
 
Old 02-11-2016, 09:59 AM   #9
chris_crunch
Member
 
Registered: Jan 2016
Location: Braintree, Essex
Distribution: Ubuntu 14.04
Posts: 107

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by grail View Post
You have mentioned a mentor, which would lead me to guess you are taking a course ... is there any reason you have not asked your teacher or mentor these questions?

In future you may want to alter your questions to advise that you are using anaconda instead of standard python otherwise you will receive answers (like my first one) that are irrelevant.
No, I am not taking a course. It's a rather complicated situation. Hahaha.

Yeah sorry about that. At the time I didn't even realize what anaconda was. Infact I still don't really. It seems like much more than a python distribution.
Nevertheless tanks for your help. I would love to understand the theory more behind what is going on here, so I will continue to crawl through pages on google. (I'm a bit thick with this stuff). I know you have more important things to do that to teach everything to a newbie but if you could point me in the right direction to sources you think are good, I'm all ears.

Chris.
 
Old 02-11-2016, 10:41 AM   #10
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,769

Rep: Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052Reputation: 3052
Not at all an issue being a noobie (still there myself for many things ).

Just pointing out that asking for help for a particular thing (like python) but really meaning something else (like anaconda) makes it tough for those who do know about one or the other to help you

On a side note, is there a reason you went with anaconda instead of learning python first? ( I only ask as it seems a little strange to go after something not main stream if only in the learning phase )

Anyhoo, hope you get there
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: NumPy python tutorial LXer Syndicated Linux News 0 11-13-2014 01:11 AM
New user: python numpy import error CosmicThespian Linux - Newbie 13 10-17-2011 10:14 PM
[SOLVED] python : NumPy : Array, Matrix Formatting cin_ Programming 2 08-05-2011 08:56 PM
python error , import numpy ufmale Programming 2 08-26-2008 12:59 AM
Visual Python/Numpy uranologist Linux - Software 0 09-28-2003 11:08 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 10:43 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration