JeanLeGrand
Posts: 8
Joined: Fri Jan 19, 2018 11:28 pm

Difference Running program from Python Shell or Terminal

Thu Feb 01, 2018 1:00 pm

I have a program that perfectly runs under Terminal but when I run it from Python 3 Shell it gives errors. Anybody an idea how to solve it

Traceback (most recent call last):
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 16, in <module>
from . import multiarray
ImportError: libf77blas.so.3: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/pi/grove_led_blink.py", line 37, in <module>
from grovepi import *
File "/home/pi/Desktop/GrovePi/Software/Python/grovepi.py", line 50, in <module>
import numpy
File "/home/pi/.local/lib/python3.5/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/home/pi/.local/lib/python3.5/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/home/pi/.local/lib/python3.5/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/home/pi/.local/lib/python3.5/site-packages/numpy/core/__init__.py", line 26, in <module>
raise ImportError(msg)
ImportError:
Importing the multiarray numpy extension module failed. Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control). Otherwise reinstall numpy.

Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
[/color]

klricks
Posts: 6441
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Difference Running program from Python Shell or Terminal

Thu Feb 01, 2018 2:05 pm

Does it work from Python 2 shell?
Note that terminal defaults to Python 2 unless you specifically use python3.
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

JeanLeGrand
Posts: 8
Joined: Fri Jan 19, 2018 11:28 pm

Re: Difference Running program from Python Shell or Terminal

Thu Feb 01, 2018 4:55 pm

Yes it does,

Any manner to change it defaulting Python 3 as main Shell ??

User avatar
penguintutor
Posts: 376
Joined: Tue May 08, 2012 9:11 am
Location: UK
Contact: Website

Re: Difference Running program from Python Shell or Terminal

Fri Feb 02, 2018 1:34 pm

Any manner to change it defaulting Python 3 as main Shell ??
Is that really what you want to do, as that will break it when you run from the shell as well as from the python shell?

If so then the version of python that runs is based on a link in /usr/bin - so that when you run /usr/bin/python it calls /usr/bin/python2.7
You can remove that link and replace it with a link to /usr/bin/python3.5 - however there is a risk that could break something else that can only run under Python 2, so I'd only do that if you know what you are doing.

A better alternative is just to type python3 whenever you want to run the python shell.

This won't fix your problem though.

It sounds like the real problem is due to a NumPy not being installed correctly for Python 3. Did you try installing NumPy manually?

It is available in apt so you could

Code: Select all

sudo apt-get install python3-numpy
or if it has been installed previously but isn't working then

Code: Select all

sudo apt-get install --reinstall python3-numpy

Return to “General discussion”