Skip to content
← Back to Community
python sklearn import bug in classrooms
Profile icon
DougLeith_17

Module import works fine in a standalone repl but not always within a classroom e.g. try

import sklearn

within a classroom and you'll see the error:

ModuleNotFoundError: No module named 'sklearn'

As I say, things work fine in a standalone repl where this line caused the following output:

Collecting scikit_learn
Downloading https://files.pythonhosted.org/packages/9f/c5/e5267eb84994e9a92a2c6a6ee768514f255d036f3c8378acfa694e9f2c99/scikit_learn-0.21.3-cp37-cp37m-manylinux1_x86_64.whl (6.7MB)

Anyone else see this behaviour too ?

Voters
Profile icon
ArlindoAlcntara
Profile icon
DougLeith_17
Comments
hotnewtop
Profile icon
DougLeith_17

sorted using requirements.txt, but strange that problem only happens inside classroom. lack of response by replt folks disappointing too seeing as I have a paid subscription and use the classroom with >200 students. t

Profile icon
DougLeith_17

here's a workaround for this issue in classrooms (it doesn't arise in standlone scripts). add the following to import sklearn manually:

i’ve posted a workaround for this on blackboard. add the following lines at the top of main.py:

import sys
import subprocess
subprocess.check_call([sys.executable, '-m', 'pip', 'install', 'sklearn'])

its not nice, and it would be better of the good repl.it folks fixed up importing of module dependencies in classrooms to be like that for standalone scripts.