Intento utilizar sum
en un programa Python pero cuando ejecuto el siguiente script me dice que no tengo NumPy.
:~$ ./testPostreSQLPython.py
Traceback (most recent call last):
File "./testPostreSQLPython.py", line 10, in <module>
import numpy as np
ImportError: No module named numpy
Entonces hago la siguiente instalación :
:~$ pip install numpy
Requirement already satisfied: numpy in ./anaconda2/lib/python2.7/site-packages
... pero el error no se soluciona:
:~$ ./testPostreSQLPython.py
Traceback (most recent call last):
File "./testPostreSQLPython.py", line 10, in <module>
import numpy as np
ImportError: No module named numpy
Pienso que ésta respuesta de @workpioupiou puede ser correcta. Parece que es a causa del VirtualEnv (una herramienta para crear entornos Python aislados) con elementos Python preinstalados.
Actualización
He intentado hacer lo que me propone @FZNB, pero sigue con el mismo problema:
:~$ conda update conda
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/antoine/anaconda2:
#
conda 4.3.18 py27_0
:~$ conda update numpy
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/antoine/anaconda2:
#
numpy 1.12.1 py27_0
:~$ conda install numpy
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/antoine/anaconda2:
#
numpy 1.12.1 py27_0
Actualización 22/5
:~$ whereis python
python: /usr/bin/python3.5m-config /usr/bin/python /usr/bin/python3.5m /usr/bin/python3.5-config /usr/bin/python2.7 /usr/bin/python2.7-config /usr/bin/python3.5 /usr/lib/python2.7 /usr/lib/python3.5 /etc/python /etc/python2.7 /etc/python3.5 /usr/local/lib/python2.7 /usr/local/lib/python3.5 /usr/include/python3.5m /usr/include/python2.7 /usr/include/python3.5 /usr/share/python /home/antoine/anaconda2/bin/python /home/antoine/anaconda2/bin/python2.7 /usr/share/man/man1/python.1.gz
Y
:~$ conda create --name pythontests python=2 numpy
Fetching package metadata .........
Solving package specifications: .
Package plan for installation in environment /home/antoine/anaconda2/envs/pythontests:
The following NEW packages will be INSTALLED:
mkl: 2017.0.1-0
numpy: 1.12.1-py27_0
openssl: 1.0.2k-2
pip: 9.0.1-py27_1
python: 2.7.13-0
readline: 6.2-2
setuptools: 27.2.0-py27_0
sqlite: 3.13.0-0
tk: 8.5.18-0
wheel: 0.29.0-py27_0
zlib: 1.2.8-3
Proceed ([y]/n)?
openssl-1.0.2k 100% |################################| Time: 0:00:02 1.60 MB/s
readline-6.2-2 100% |################################| Time: 0:00:00 1.65 MB/s
tk-8.5.18-0.ta 100% |################################| Time: 0:00:01 1.74 MB/s
zlib-1.2.8-3.t 100% |################################| Time: 0:00:00 1.77 MB/s
setuptools-27. 100% |################################| Time: 0:00:00 1.58 MB/s
wheel-0.29.0-p 100% |################################| Time: 0:00:00 1.91 MB/s
#
# To activate this environment, use:
# > source activate pythontests
#
# To deactivate this environment, use:
# > source deactivate pythontests
#
:~$ ./testPostreSQLPython.py
Traceback (most recent call last):
File "./testPostreSQLPython.py", line 8, in <module>
import numpy as np
ImportError: No module named numpy
(pythontests) antoine@antoine-Inspiron-3543:~$ conda install numpy
Fetching package metadata .........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /home/antoine/anaconda2/envs/pythontests:
#
numpy 1.12.1 py27_0
(pythontests) antoine@antoine-Inspiron-3543:~$ ./testPostreSQLPython.py
Traceback (most recent call last):
File "./testPostreSQLPython.py", line 8, in <module>
import numpy as np
ImportError: No module named numpy
python 3
debes instalaro conpip3
:~$ python -V
tengo :Python 2.7.13 :: Anaconda custom (64-bit)
python testPostreSQLPython.py
?#!/usr/bin/python
. Si fuerzo el intérprete todo funciona como se esperaba