导入sklearn时出现python版本错误

时间:2019-07-11 03:47:11

标签: python-3.x ubuntu scikit-learn path-variables

当我尝试执行python程序时遇到问题。我需要从sklearn.metrics.pairwise导入pairwise_distances,并且我正在使用此命令行“从sklearn.metrics.pairwise导入pairwise_distances”。但是,当我执行它时,我收到以下错误消息:

Traceback (most recent call last):
  File "/home/renatosouza/TimeSeries/ProgramsAndScripts/bow/projects/Kmedoid_py/kmedoid.py", line 2, in <module>
    from sklearn.metrics.pairwise import pairwise_distances
ImportError: No module named 'sklearn'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in <module>
    import apport.fileutils
  File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in <module>
    from apport.packaging_impl import impl as packaging
  File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 20, in <module>
    import apt
  File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in <module>
    import apt_pkg
ImportError: No module named 'apt_pkg'

Original exception was:
Traceback (most recent call last):
  File "/home/renatosouza/TimeSeries/ProgramsAndScripts/bow/projects/Kmedoid_py/kmedoid.py", line 2, in <module>
    from sklearn.metrics.pairwise import pairwise_distances
ImportError: No module named 'sklearn'
K-Medoid  extratction completed...
```


I'm already getting the packages necessary of sklearn and apt_pkg, but I guess I have a problem with python version. I do have installed the 3.4 (that it's set to python3) and 3.5 (I have to use python3.5 to use it). But when I execute the script I always get this error. And the linux version is 14.04.4 LTS (GNU/Linux 3.19.0-56-generic x86_64).

To use the sklearn it's necessary the python version at least 3.5, but when I'm executing it get the version 3.4 and don't find the installed modules. How I can solve it? I tried a lot of different things that I find here.

0 个答案:

没有答案