Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
>>> 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?
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 09:27 AM.
Reason: Increased readability - added info
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?
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 03:47 AM.
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 04:02 AM.
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 04:04 AM.
Reason: correct insertion of code tags
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.
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.
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 )
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.