ModuleNotFoundError: No module named 'surprise' - python

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.

Related

ModuleNotFoundError: No module named 'pdfplumber'

I would like to import pdfplumber and tried
import pdfplumber
and caught error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-2-b3d6737fd8e1> in <module>
----> 1 import pdfplumber
ModuleNotFoundError: No module named 'pdfplumber'
Tried to install using pip3 install pdfplumber and it returned:
Requirement already satisfied: pdfplumber in c:\python38\lib\site-packages (0.5.26)
Requirement already satisfied: pdfminer.six==20200517 in c:\python38\lib\site-packages (from pdfplumber) (20200517)
Requirement already satisfied: Wand in c:\python38\lib\site-packages (from pdfplumber) (0.6.5)
Requirement already satisfied: Pillow>=7.0.0 in c:\python38\lib\site-packages (from pdfplumber) (7.2.0)
Requirement already satisfied: sortedcontainers in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (2.3.0)
Requirement already satisfied: chardet in c:\users\harper.guo\appdata\roaming\python\python38\site-packages (from pdfminer.six==20200517->pdfplumber) (3.0.4)
Requirement already satisfied: pycryptodome in c:\python38\lib\site-packages (from pdfminer.six==20200517->pdfplumber) (3.10.1)
WARNING: You are using pip version 20.3.3; however, version 21.0.1 is available.
You should consider upgrading via the 'c:\python38\python.exe -m pip install --upgrade pip' command.
But Command Prompt showed that I already have installed the module?
>>> pdfplumber
<module 'pdfplumber' from 'C:\\Python38\\lib\\site-packages\\pdfplumber\\__init__.py'>
But import pdfplumber returned the same erro. How to import pdfplumber?
I guess it has to do with the Python version that I used.
In the top right hand corner of VS Code it shows that my Python version was Python 3
Clicking on it and changing it to Python 3.8.5 and the code worked. This was done after I restarted VS Code and my laptop, and created new path.
Creating a new path in Environment Variables following these resources:
1. 'pip' is not recognized as an internal or external command
2. 2020 How to Fix "No Module Named..." Error in Python | Python Tutorial
3. Python Virtual Environments: A Primer
4. '' is not recognized as an internal or external command, operable program or batch file

Can't import Pyomo in Jupyter Notebook

I'm trying to import pyomo in Jupyter Notebook, I ran the following code:
!pip3 install pyomo
import pyomo
THEN it came back:
Requirement already satisfied: pyomo in /Users/*/Library/Python/3.8/lib/python/site-packages (5.7.3) Requirement already satisfied: PyUtilib>=6.0.0 in /Users/*/Library/Python/3.8/lib/python/site-packages (from pyomo) (6.0.0)
Requirement already satisfied: six>=1.4 in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from pyomo) (1.15.0) Requirement already satisfied: ply in /Users/*/Library/Python/3.8/lib/python/site-packages (from pyomo) (3.11)
Requirement already satisfied: nose in /Users/*/Library/Python/3.8/lib/python/site-packages (from PyUtilib>=6.0.0->pyomo) (1.3.7)
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available. You should consider upgrading via the 'pip install --upgrade pip' command. --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-5-7105a3440ba3> in <module> 1 get_ipython().system('pip3 install pyomo') ----> 2 import pyomo
ModuleNotFoundError: No module named 'pyomo'
I think I already installed pyomo, but when I try to import the module, it cannot be found.
Please someone helps to resolve this issue.
import pyomo doesnt work. as written in the doc you should use this package like:
from pyomo.environ import * or like:
import pyomo.environ

'ModuleNotFoundError' after installing the packages

I am using a module for a work called cryptography and tried to install it via:
C:\Users\Administrator\Desktop>python -m pip install cryptography
Here is a copy of the cmd window:
Collecting cryptography
Using cached cryptography-3.2-cp38-cp38-win32.whl (1.3 MB)
Requirement already satisfied: six>=1.4.1 in c:\users\administrator\appdata\roaming\python\python38\site-packages (from cryptography) (1.15.0)
Requirement already satisfied: cffi!=1.11.3,>=1.8 in c:\program files (x86)\python38\lib\site-packages (from cryptography) (1.14.3)
Requirement already satisfied: pycparser in c:\program files (x86)\python38\lib\site-packages (from cffi!=1.11.3,>=1.8->cryptography) (2.20)
Installing collected packages: cryptography
Successfully installed cryptography-3.2
Then when I tried using the program it just did not work:
C:\Users\Administrator\Desktop>main.py
Traceback (most recent call last):
File "C:\Users\Administrator\Desktop\ape esse\main.py", line 3, in <module>
from cryptography.fernet import Fernet
ModuleNotFoundError: No module named 'cryptography'
It gives the same error, as if not installed, and I don't know what to do.
One of my friends said it was a problem with my python installation but I've already repaired and reinstalled it and it still gives the same error.
I installed it now using
pip install cryptography --no-cache-dir and it worked perfectly fine on python 3.8.5.
so you might want to try it.

ModuleNotFoundError- Requests (despite installation attemps showing "requirement already satisfied")

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

Installing Sci Kit Learn on Mac OSX

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

Categories