0

In my python virtual environment, I installed sklearn of verison 0.19.2. Then I started a python interpreter:

import sklearn
sklearn.__version__ # 0.19.2
import sys, subprocess
sys.path.insert(0, '/tmp/user')
subprocess.call(['python','-m','pip','install','scikit-learn','--target=/tmp/user'])

I could see it's installed:

Collecting scikit-learn
...
Installing collected packages: numpy, scipy, scikit-learn
Successfully installed numpy-1.16.2 scikit-learn-0.20.3 scipy-1.2.1

Then I reload sklearn, I got error:

reload(sklearn)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/tmp/user/sklearn/__init__.py", line 65, in <module>
    from .utils._show_versions import show_versions
ImportError: No module named _show_versions

Any idea of what's the issue? Thanks!

kww
  • 411
  • 4
  • 12
  • 21

1 Answers1

0

You can use reload

from importlib import reload

sklearn = reload(sklearn)

See here for more details.

jottbe
  • 4,228
  • 1
  • 15
  • 31