I have installed numpy, scipy, scikit learn and other required packages. Still when I try to import them in python, it shows no module found.
pip install -U numpy scipy scikit-learn
Requirement already up-to-date: numpy in /usr/lib/python2.7/dist-packages
Collecting scipy
Downloading scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (39.5MB)
100% |████████████████████████████████| 39.5MB 32kB/s
Requirement already up-to-date: scikit-learn in /home/tecsadmin/.local/lib/python2.7/site-packages
Installing collected packages: scipy
Found existing installation: scipy 0.17.0
DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling scipy-0.17.0:
Exception:
Traceback (most recent call last):
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/home/tecsadmin/.local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/dist-packages/scipy-0.17.0.egg-info'
tecsadmin#BLITZ:~/.local/lib/python2.7/site-packages/sklearn/__check_build$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>>
Update
admin#BLITZ:~$ sudo pip install -U numpy scipy scikit-learn
[sudo] password for tecsadmin:
The directory '/home/tecsadmin/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/tecsadmin/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: numpy in /usr/lib/python2.7/dist-packages
Collecting scipy
Downloading scipy-0.17.1-cp27-cp27mu-manylinux1_x86_64.whl (39.5MB)
100% |████████████████████████████████| 39.5MB 32kB/s
Requirement already up-to-date: scikit-learn in ./.local/lib/python2.7/site-packages
Installing collected packages: scipy
Found existing installation: scipy 0.17.0
DEPRECATION: Uninstalling a distutils installed project (scipy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling scipy-0.17.0:
Successfully uninstalled scipy-0.17.0
Successfully installed scipy-0.17.1
tecsadmin#BLITZ:~$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
UPDATE 2
tecsadmin#BLITZ:~$ pip freeze | grep numpy
numpy==1.11.0
tecsadmin#BLITZ:~$ pip freeze | grep scipy
scipy==0.17.1
tecsadmin#BLITZ:~$ pip freeze | grep scikit-learn
scikit-learn==0.17.1
tecsadmin#BLITZ:~$ python
Python 2.7.5 (default, Jun 17 2016, 04:41:21)
[GCC 5.3.1 20160413] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named scipy
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
Not sure if related but you are having a permission denied error, try with
sudo pip install -U numpy scipy scikit-learn
To double check your installation run pip freeze
$ pip freeze | grep numpy
$ numpy==1.9.2
That way you really check if it has been succesfuly installed
Also I would suggest you to use python virtual environments https://virtualenv.pypa.io/en/stable/ so you dont have to play with sudo permissions
You haven't installed the libs you got error 13 permission denied. Reinstall them using the command:
sudo pip install numpy scipy scikit-learn
Related
Week before perfectly working numpy stopped working under Python 3.7 on Raspbian GNU/Linux 10 (buster). Still works with Python 2.7.
~ $ python3
Python 3.7.3 (default, Apr 3 2019, 05:39:12)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/numpy/core/__init__.py", line 24, in <module>
from . import multiarray
File "/usr/local/lib/python3.7/dist-packages/numpy/core/multiarray.py", line 14, in <module>
from . import overrides
File "/usr/local/lib/python3.7/dist-packages/numpy/core/overrides.py", line 7, in <module>
from numpy.core._multiarray_umath import (
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 "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.7/dist-packages/numpy/__init__.py", line 142, in <module>
from . import core
File "/usr/local/lib/python3.7/dist-packages/numpy/core/__init__.py", line 54, in <module>
raise ImportError(msg)
ImportError:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "/usr/bin/python3",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: libf77blas.so.3: cannot open shared object file: No such file or directory
Tried to reinstall:
~ $ sudo pip3 uninstall -y numpy
Uninstalling numpy-1.18.1:
Successfully uninstalled numpy-1.18.1
~ $ sudo pip3 install numpy
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting numpy
Using cached https://www.piwheels.org/simple/numpy/numpy-1.18.1-cp37-cp37m-linux_armv7l.whl
Installing collected packages: numpy
Successfully installed numpy-1.18.1
Did not work.
Tried first reinstalling setuptools using sudo pip3 uninstall -y setuptools, returns:
Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'setuptools'. No files were found to uninstall.
But when I try to install it using sudo pip3 install setuptools, returns:
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (40.8.0)
I am confused, do not know what to do.
This has me pretty confused. I've installed pyad using pip and everything seems fine:
C:\WINDOWS\system32>pip install pyad
Collecting pyad
Using cached pyad-0.5.16.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools in c:\python35\lib\site-packages (from pyad)
Requirement already satisfied (use --upgrade to upgrade): pywin32 in c:\python35\lib\site-packages (from pyad)
Installing collected packages: pyad
Running setup.py install for pyad ... done
Successfully installed pyad-0.5.16
But when I try to use it, I get an error that complains about not finding adbase:
C:\WINDOWS\system32>python
Python 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyad import aduser
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'
>>> import pyad
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python35\lib\site-packages\pyad\__init__.py", line 1, in <module>
from adbase import set_defaults as pyad_setdefaults
ImportError: No module named 'adbase'
This is odd, because if I try to uninstall pyad or if I check the site-packages directory, adbase is definitely there:
C:\WINDOWS\system32>pip uninstall pyad
Uninstalling pyad-0.5.16:
c:\python35\lib\site-packages\pyad-0.5.16-py3.5.egg-info
c:\python35\lib\site-packages\pyad\__init__.py
c:\python35\lib\site-packages\pyad\__pycache__\__init__.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adcomputer.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\addomain.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adgroup.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adquery.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\adsearch.cpython-35.pyc
c:\python35\lib\site-packages\pyad\__pycache__\pyad.cpython-35.pyc
c:\python35\lib\site-packages\pyad\adbase.py
c:\python35\lib\site-packages\pyad\adcomputer.py
c:\python35\lib\site-packages\pyad\adcontainer.py
c:\python35\lib\site-packages\pyad\addomain.py
c:\python35\lib\site-packages\pyad\adgroup.py
c:\python35\lib\site-packages\pyad\adobject.py
c:\python35\lib\site-packages\pyad\adquery.py
c:\python35\lib\site-packages\pyad\adsearch.py
c:\python35\lib\site-packages\pyad\aduser.py
c:\python35\lib\site-packages\pyad\pyad.py
c:\python35\lib\site-packages\pyad\pyadconstants.py
c:\python35\lib\site-packages\pyad\pyadexceptions.py
c:\python35\lib\site-packages\pyad\pyadutils.py
Proceed (y/n)?
pyad directory contents
I'm really not sure what else to try. I've run everything under an elevated command prompt, so it's not a permissions issue. I even tried downloading pyad and installing it using setup.py, but I had the same problem with that. adbase is definitely there, and I can't figure out why Python isn't finding it.
That's a bug on pyad part. They're importing adbase as if it were a standalone module or package, and that's why it does not work. The proper way to fix this would be to change the import to an absolute import from pyad.adbase import ... or relative from .adbase import ....
However, if you check the master branch on Github, you will see that they have actually fixed it. But that's not all, if you check their setup.py you'll see that the version on Github is 0.5.15, while the last version on PyPI, which is the one you have installed, is 0.5.16. Weird.
I suggest you to install the package directly from Github, and that should take care of the problem. To do that, first uninstall pyad and then run
pip install https://github.com/zakird/pyad/archive/master.zip
i am using python 2.7.11 on virtualenv in lubuntu 12.04.(dont own a good laptop its dell latitude d600)
Python 2.7.11 (default, Mar 4 2016, 04:38:41)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
import sqlite3
Traceback (most recent call last):
File "", line 1, in
File "/home/maharshi/.localpython/lib/python2.7/sqlite3/init.py", line 24, in
from dbapi2 import *
File "/home/maharshi/.localpython/lib/python2.7/sqlite3/dbapi2.py", line 28, in
from _sqlite3 import *
ImportError: No module named _sqlite3
i have installed pysqlite using pip and it says successfull.
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ which python
/home/maharshi/virtualenvs/p2.7/bin/python
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ which pip
/home/maharshi/virtualenvs/p2.7/bin/pip
(p2.7) maharshi#maharshi-Latitude-D600:~/code$ pip install pysqlite
Requirement already satisfied (use --upgrade to upgrade): pysqlite in /home/maharshi/virtualenvs/p2.7/lib/python2.7/site-packages
i also installed it manually at both locations i.e
~/virtualenvs/p2.7/
~/.localpython/ (from where i created the virtualenv)
i also installed "libsqlite3-dev(as suggested by one of the posts)" i.e
sudo apt-get install libsqlite3-dev
Thank you in advance.
Try doing the whole process again installing python in virtualenv...as i understand when you add the libraries needed for SqlLite it wont affect the virtualenv python so you have to re-do all the steps and it will compile with the required libraries....
Similar to this question I am trying to install the blink1 library on raspbian.
But no matter what I try, I get:
>>>import blink1
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import blink1
ImportError: No module named blink1
I installed it via pip and it is in the correct path as far as I understand it:
pi#raspberrypi ~ $ ls /usr/local/lib/python2.7/dist-packages/
blink1 python_jenkins-0.4.8.dist-info
blink1-0.0.12.dist-info pyusb-1.0.0rc1.egg-info
blink1_tests setuptools
click setuptools-18.3.1.dist-info
click-5.1.dist-info six-1.9.0.dist-info
configobj-5.0.6.dist-info six.py
configobj.py six.pyc
configobj.pyc usb
easy_install.py validate.py
easy_install.pyc validate.pyc
jenkins _version.py
_markerlib _version.pyc
pbr webcolors-1.5.dist-info
pbr-1.7.0.dist-info webcolors.py
pip webcolors.pyc
pip-7.1.2.dist-info wheel
pkg_resources wheel-0.24.0.dist-info
I don't know what else I should try now...
Edit: it does not seem to work with pyhthon3 either:
Python 3.2.3 (default, Mar 1 2013, 11:53:50)
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
>>> import blink1
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import blink1
ImportError: No module named blink1
$ sudo pip-3.2 install blink1
Requirement already satisfied (use --upgrade to upgrade): blink1 in /usr/local/lib/python3.2/dist-packages
Edit 2: the last issue might have something to do with the fact that on this installation, the sys.path does only contain the 2.7 libraries, not the v3 dist-packages...
The file __init__.py is missing from /usr/local/lib/python2.7/dist-packages/blink1/
If you run
touch /usr/local/lib/python2.7/dist-packages/blink1/__init__.py
it should start working.
Reference:
https://github.com/todbot/blink1/pull/224
I installed django using pip, however typing import django in the python console yields the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named django
When I run pip install django I get the following:
Requirement already satisfied (use --upgrade to upgrade): django in /usr/local/lib/python2.7/site-packages
Cleaning up...
However running which python in the terminal yields the following:
/usr/bin/python
I am wondering whether django does not import because a version I installed using homebrew conflicts with the mac pre-installed version.
I should mention that i am able to import django in the console when in the directory /usr/local/lib/python2.7/site-packages
Any help is appreciated.
You should import django, not Django, watch the case.
Demo:
$ pip install django
Requirement already satisfied (use --upgrade to upgrade): django in ...
Cleaning up...
$ python
Python 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import Django
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named Django
>>> import django
>>>
I couldn't fix the $PATH conflict between my OSX default version (2.7.10) and my pip installed one (3.8). Instead, I manually specify the entire path when calling django-admin:
Go to your project folder in console and type (check your version first).
your_proyect_folder$ python3 /Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/django/bin/django-admin.py startproject your_folder_name