如何在PythonAnywhere中导入库并在Python笔记本中使用它们?

问题描述 投票:0回答:1

我同时更新和安装软件包/库,但是只能通过Python3.6控制台使用它们。

10:40 ~ $ pip3.6 install -U --user scikit-learn                                                                                                                                                                                                                                         
Requirement already up-to-date: scikit-learn in ./.local/lib/python3.6/site-packages
Requirement already up-to-date: numpy>=1.11.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: joblib>=0.11 in ./.local/lib/python3.6/site-packages (from scikit-learn)
Requirement already up-to-date: scipy>=0.17.0 in ./.local/lib/python3.6/site-packages (from scikit-learn)

使用pip安装时,它失败并显示:]

10:40 ~ $ pip install -U --user scikit-learn                                                                                                                                                                                                                                            
Collecting scikit-learn
  Using cached https://files.pythonhosted.org/packages/18/28/5a48b00599b476875415b97bdfdb3849bafb31183c1d785501dbc8a77aa2/scikit-learn-0.22.1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-JYw8w1/scikit-learn/setup.py", line 47, in <module>
        import sklearn
      File "sklearn/__init__.py", line 81, in <module>
        from . import __check_build  # noqa: F401
      File "sklearn/__check_build/__init__.py", line 46, in <module>
        raise_build_error(e)
      File "sklearn/__check_build/__init__.py", line 41, in raise_build_error
        %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
    ImportError: No module named _check_build
    ___________________________________________________________________________
    Contents of sklearn/__check_build:
    __init__.py               _check_build.pyx          __init__.pyc
    setup.py
    ___________________________________________________________________________
    It seems that scikit-learn has not been built correctly.

    If you have installed scikit-learn from source, please do not forget
    to build the package before using it: run `python setup.py install` or
    `make` in the source directory.

    It appears that you are importing a local scikit-learn source tree. For
    this, you need to have an inplace install. Maybe you are in the source
    directory and you need to try from another location.

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-JYw8w1/scikit-learn/

我同时更新和安装软件包/库,但是只能通过Python3.6控制台使用它们。 10:40〜$ pip3.6安装-U --user scikit-learn ...

pythonanywhere
1个回答
0
投票

当您在虚拟环境之外的PythonAnywhere上运行pip时,它将安装python2的软件包。 scikit-learn的最新版本为0.20.4。因此,请使用python2

© www.soinside.com 2019 - 2024. All rights reserved.