On my OSX laptop I have installed Sci Kit Learn by copying and pasting this command pip install -U numpy scipy scikit-learn to terminal as instructed on this page.
This is the result I get when I run the command on terminal again:
Requirement already up-to-date: numpy in /usr/local/lib/python2.7/site- packages
Requirement already up-to-date: scipy in /usr/local/lib/python2.7/site-packages
Requirement already up-to-date: scikit-learn in /usr/local/lib/python2.7/site-packages
Cleaning up...
This is the error message I get when I run from sklearn import datasets on Python 3.3.4. IDLE: (I was trying this example)
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
from sklearn import dataset
ImportError: No module named 'sklearn'
What is the issue here?
You have the packages installed for python 2.7 as you can see in the log
Requirement already up-to-date: numpy in /usr/local/lib/python2.7/site-packages
and you're running with python 3.3.4.
So either run it with python 2.7.x or install the packages for python3.x. How? Check here
Related
I have installed scikit-surprise in Windows10.
C:\Users\Cosmos Lord>pip install scikit-surprise
Requirement already satisfied: scikit-surprise in c:\users\cosmos
lord\appdata\roaming\python\python37\site-packages (1.1.0) Requirement
already satisfied: joblib>=0.11 in c:\users\cosmos
lord\appdata\roaming\python\python37\site-packages (from
scikit-surprise) (0.14.0) Requirement already satisfied: numpy>=1.11.2
in c:\users\cosmos lord\appdata\roaming\python\python37\site-packages
(from scikit-surprise) (1.17.2) Requirement already satisfied:
scipy>=1.0.0 in c:\users\cosmos
lord\appdata\roaming\python\python37\site-packages (from
scikit-surprise) (1.3.1) Requirement already satisfied: six>=1.10.0 in
c:\users\cosmos lord\appdata\roaming\python\python37\site-packages
(from scikit-surprise) (1.12.0)
But I am still unable to import surprise module.
In Spyder3 kernel, the following error is shown:
import surprise
Traceback (most recent call last):
File "", line 1, in
import surprise
ModuleNotFoundError: No module named 'surprise'
Whereas in IDLE(Python-32 bit), the following error is shown:
Traceback (most recent call last): File "C:/Users/Cosmos
Lord/Documents/Flask Projects/New folder/aaa.py", line 1, in
import surprise File "C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise__init__.py",
line 3, in
from .prediction_algorithms import AlgoBase File "C:\Users\Cosmos
Lord\AppData\Roaming\Python\Python37\site-packages\surprise\prediction_algorithms__init__.py",
line 23, in
from .algo_base import AlgoBase File "C:\Users\Cosmos Lord\AppData\Roaming\Python\Python37\site-packages\surprise\prediction_algorithms\algo_base.py",
line 10, in
from .. import similarities as sims ImportError: cannot import name 'similarities' from 'surprise' (C:\Users\Cosmos
Lord\AppData\Roaming\Python\Python37\site-packages\surprise__init__.py)
How do I import surprise? Any help would be much appreciated.
From within Spyder kernel (console), run pip install surprise
Then restart the kernel.
It solved the problem for me
try:
pip install numpy
pip install scikit-surprise
if your problem didn't solve, then use conda forge:
conda install -c conda-forge scikit-surprise
Welcome to Stackoverflow
Surprise uses Cython, which requires a C compiler to be installed on the system.
More about Cython
Installing Visual studio C++2014 could sovle this issue.
Try installing Visual Studio on your machine.
I think it's because your current working environment and the environment the surprise module has been installed into are different.
If you are sure that you are in the right env, kindly change your IDE. I changed mine to Jupyterlab and everything started working correctly.
When I run the code below to attempt to import a few of the usual Python libraries for API interaction... I get a ModuleNotFoundError on the import line of code.
I verified that it is indeed installed on my machine via pip3. I then tried uninstalling it and reinstalling it. When that didn't work I tried running the installation as a shell command in my Jupyter notebook. The same errors persisted.
Please note: what I am referring to as "it" is either the requests or json library for Python; I am encountering the same errors with each.
#right on the import line is where the error happens, the code is simple though...
import requests
import json
Here is the traceback...
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-021831bd5cc5> in <module>
1 # Dependencies
2 get_ipython().system(' pip3 install requests')
----> 3 import requests
4 import json
ModuleNotFoundError: No module named 'requests'
And here is the "requirement already satisfied" statement from Terminal...
(base) Computer:~ User$ pip3 install requests
Requirement already satisfied: requests in ./anaconda3/lib/python3.7/site-packages (2.22.0)
Requirement already satisfied: idna<2.9,>=2.5 in ./anaconda3/lib/python3.7/site-packages (from requests) (2.8)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in ./anaconda3/lib/python3.7/site-packages (from requests) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in ./anaconda3/lib/python3.7/site-packages (from requests) (2019.6.16)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in ./anaconda3/lib/python3.7/site-packages (from requests) (1.24.2)
Sorry I’ve reputation to comment.
Pleas look at your env where you install the package.
You’re running on base environment maybe you’re using Anaconda, and then run Python without that environment. So the package won’t be seen bye your editor or terminale.
Could you add more information on where you use python?
I was facing the same problem on mac OSX, when I did "pip install requests", then I installed with "sudo" and it worked.
On OSX/Linux :
Use $ sudo pip install requests if you have pip installed.
Alternatively you can also use sudo easy_install -U requests if you have easy_install installed.
For centOS: yum install python-requests
Reference: [ImportError: No module named requests
Trying to install tensorflow. Tried anaconda, it worked but affected my other program. Then decided to use pip install.
But after I installed it, I just can't import it within ipython.
Here are the messages: I tried uninstall and reinstall.
pip install tensorflow
Requirement already satisfied (use --upgrade to upgrade): tensorflow in /Library/Python/2.7/site-packages
Cleaning up...
First I try to import in ipython:
In [1]: import tensorflow
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a649b509054f> in <module>()
----> 1 import tensorflow
ImportError: No module named tensorflow
And then I copied the folder of tensorflow from /Library/Python/2.7/site-packages to /usr/local/lib/python2.7/site-packages/. I try to import:
In [1]: import tensorflow
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a649b509054f> in <module>()
----> 1 import tensorflow
/Library/Python/2.7/site-packages/tensorflow/__init__.py in <module>()
21 from __future__ import print_function
22
---> 23 from tensorflow.python import *
24
25
/Library/Python/2.7/site-packages/tensorflow/python/__init__.py in <module>()
57 please exit the tensorflow source tree, and relaunch your python interpreter
58 from there.""" % traceback.format_exc()
---> 59 raise ImportError(msg)
60
61 from tensorflow.core.framework.node_def_pb2 import *
ImportError: Traceback (most recent call last):
File "tensorflow/python/__init__.py", line 53, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "tensorflow/core/framework/graph_pb2.py", line 6, in <module>
from google.protobuf import descriptor as _descriptor
ImportError: No module named google.protobuf
Error importing tensorflow. Unless you are using bazel,
you should not try to import tensorflow from its source directory;
please exit the tensorflow source tree, and relaunch your python interpreter
from there.
However, I have protobuf installed under /Library/Python/2.7/site-packages as well.
I find out this version of ipython is using macports python package directory:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/
I am not sure how to let ipython search for the pip installed directory.
I reinstalled the tensorflow again as it is described on the website:
sudo pip install --upgrade $TF_BINARY_URL
Password:
Downloading/unpacking https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0rc0-py2-none-any.whl
Downloading tensorflow-0.11.0rc0-py2-none-any.whl (35.5MB): 35.5MB downloaded
Downloading/unpacking protobuf==3.0.0 (from tensorflow==0.11.0rc0)
Downloading protobuf-3.0.0-py2.py3-none-any.whl (342kB): 342kB downloaded
Requirement already up-to-date: wheel in /Library/Python/2.7/site-packages (from tensorflow==0.11.0rc0)
Requirement already up-to-date: mock>=2.0.0 in /Library/Python/2.7/site-packages (from tensorflow==0.11.0rc0)
Requirement already up-to-date: numpy>=1.11.0 in /Library/Python/2.7/site-packages (from tensorflow==0.11.0rc0)
Requirement already up-to-date: six>=1.10.0 in /Library/Python/2.7/site-packages (from tensorflow==0.11.0rc0)
Downloading/unpacking setuptools from https://pypi.python.org/packages/be/20/3f4d2fb59ddeed35532bd4e11e900abcf8019d29f4558d38169639303536/setuptools-28.2.0-py2.py3-none-any.whl#md5=02e79b1127c5a131a2dace6d30cf7f25 (from protobuf==3.0.0->tensorflow==0.11.0rc0)
Downloading setuptools-28.2.0-py2.py3-none-any.whl (467kB): 467kB downloaded
Installing collected packages: tensorflow, protobuf, setuptools
Found existing installation: protobuf 3.1.0.post1
Uninstalling protobuf:
Successfully uninstalled protobuf
Found existing installation: setuptools 18.5
Uninstalling setuptools:
Successfully uninstalled setuptools
Successfully installed tensorflow protobuf setuptools
Cleaning up...
And still no luck:
In [1]: import tensorflow
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-a649b509054f> in <module>()
----> 1 import tensorflow
OK, I got the problem fixed.
I am not sure what exactly is causing it. Because I installed all this on my RMBP, nothing wrong. But desktop just won't take it.
Solution is:
Uninstall all previously installed or half installed tensorflow, and my other packages (just two main packages). And use anaconda to install tensorflow, activate it. And use anaconda to install my other packages.
Then problem solved.
I am having difficulty installing Python Packages on Windows 10.The package name is Tabular..i have been trying over and over and it doesn't work out.her what i get when I try to install it using pip.Any help about it ?Thanks
C:\Python27\Scripts>pip install tabular
Collecting tabular
Using cached tabular-0.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "c:\users\pc\appdata\local\temp\pip-build-5mggv5\tabular\setup.py", line 50, in
raise ImportError("distribute was not found and fallback to setuptools was not allowed")
ImportError: distribute was not found and fallback to setuptools was not allowed
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\pc\appdata\local\temp\pip-build-5mggv5\tabular\
C:\Python27\Scripts>pip install distribute
Requirement already satisfied (use --upgrade to upgrade): distribute in c:\python27\lib\site-packages
Requirement already satisfied (use --upgrade to upgrade): setuptools>=0.7 in c:\python27\lib\site-packages (from distribute)
C:\Python27\Scripts>pip install --upgrade distribute
Requirement already up-to-date: distribute in c:\python27\lib\site-packages
Collecting setuptools>=0.7 (from distribute)
Downloading setuptools-25.1.6-py2.py3-none-any.whl (442kB)
100% |################################| 450kB 191kB/s
Installing collected packages: setuptools
Found existing installation: setuptools 25.1.1
Uninstalling setuptools-25.1.1:
Successfully uninstalled setuptools-25.1.1
Successfully installed setuptools-25.1.6
Tabular 0.1 has issues with Windows 10. Please fall back to 0.0.8
pip install tabular==0.0.8
Edit
For scipy installation on Windows 10 with python 2.7, instructions are at https://stackoverflow.com/a/38618044/5334188
Despite my best effors, I can't seem to get gevent or grequests working. They both rely on greenlet which I can't get working either.
I've completely installed and reinstalled python via homebrew. I haven't tried using python's installer but I don't see why that would matter. I have upgraded xcode to the latest version and installed literally every plugin. I regularly have success installing python modules via pip. I've been trying to install grequests for the last month.
Computer:
Mac OSX Yosemite Version 10.10.1
MacBook Pro (Retina, 15-inch, Late 2013)
2.3 GHz Intel Core i7
16 GB 1600 MHz DDR3
Intel Iris Pro 1536 MB
`
$ sudo pip install greenlet
Requirement already satisfied (use --upgrade to upgrade): greenlet in /usr/local/lib/python2.7/site-packages
Cleaning up...
$ sudo pip install gevent
Requirement already satisfied (use --upgrade to upgrade): gevent in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): greenlet in /usr/local/lib/python2.7/site-packages (from gevent)
Cleaning up...
$ sudo pip install grequests
Requirement already satisfied (use --upgrade to upgrade): grequests in /usr/local/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): gevent in /usr/local/lib/python2.7/site-packages (from grequests)
Requirement already satisfied (use --upgrade to upgrade): requests>=1.0.0 in /Library/Python/2.7/site-packages (from grequests)
Requirement already satisfied (use --upgrade to upgrade): greenlet in /usr/local/lib/python2.7/site-packages (from gevent->grequests)
Cleaning up...
'
>>> import grequests
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import grequests
ImportError: No module named grequests
>>> import greenlet
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import greenlet
ImportError: No module named greenlet
>>> import gevent
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import gevent
ImportError: No module named gevent
Edit:
$ which -a python
/Library/Frameworks/Python.framework/Versions/2.7/bin/python
/usr/local/bin/python
/usr/bin/python
Edit 2:
I must have broken something at some point because now none of the modules I install are coming through. The modules I've installed in the past still work but the new ones are getting the same errors as above.
After reinstalling everything, I still had the problem. I thought that /Library/Frameworks/Python.framework/Versions/2.7/bin/python was the system installed version, but it's not.
I needed to delete that and remove it from ~/.bash_profile that and then everything worked fine. I don't know if that was my only problem as the reinstall could have fixed something, but I think it was.