[英]unable to install scikit-learn from git using jupyter notebook in my windows
我正在嘗試導入 sklearn.metrics.multilabel_confusion_matrix,但由於它不在正常的 package 中,我想做的是使用安裝它:pip install git+http.//github.com/scikit-learn/scikit-learn.git
在我的 windows 中使用 jupyter 筆記本。 我也使用了命令提示符,但發生了同樣的問題。 但是當我這樣做時,會彈出一個錯誤,如下所示
它說的是與“scikit-learn 的構建輪失敗,由於 EnvironmentError 無法安裝軟件包:”相關的內容。
顯示了下面的完整對話。 請幫忙!!!
!pip install git+http://github.com/scikit-learn/scikit-learn.git
Collecting git+http://github.com/scikit-learn/scikit-learn.git
Cloning http://github.com/scikit-learn/scikit-learn.git to c:\users\intel\appdata\local\temp\pip-req-build-bg_zxcrm
Requirement already satisfied: numpy>=1.11.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (1.15.4)
Requirement already satisfied: scipy>=0.17.0 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (1.1.0)
Requirement already satisfied: joblib>=0.11 in c:\programdata\anaconda3\lib\site-packages (from scikit-learn==0.22.dev0) (0.14.0)
Building wheels for collected packages: scikit-learn
Running setup.py bdist_wheel for scikit-learn: started
Running setup.py bdist_wheel for scikit-learn: finished with status 'error'
Complete output from command C:\PROGRAMDATA\ANACONDA3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\INTEL\\AppData\\Local\\Temp\\pip-req-build-bg_zxcrm\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d C:\Users\INTEL\AppData\Local\Temp\pip-wheel-vp_d4jnx --python-tag cp37:
Partial import of sklearn during the build process.
No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
Traceback (most recent call last):
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 489, in _find_latest_available_vc_ver
return self.find_available_vc_vers()[-1]
IndexError: list index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 290, in <module>
setup_package()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 286, in setup_package
setup(**metadata)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\core.py", line 135, in setup
config = configuration()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\setup.py", line 174, in configuration
config.add_subpackage('sklearn')
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 1037, in add_subpackage
caller_level = 2)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 1006, in get_subpackage
caller_level = caller_level + 1)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\numpy\distutils\misc_util.py", line 943, in _get_configuration_from_setup_py
config = setup_module.configuration(*args)
File "sklearn\setup.py", line 81, in configuration
maybe_cythonize_extensions(top_path, config)
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\sklearn\_build_utils\__init__.py", line 43, in maybe_cythonize_extensions
with_openmp = check_openmp_support()
File "C:\Users\INTEL\AppData\Local\Temp\pip-req-build-bg_zxcrm\sklearn\_build_utils\openmp_helpers.py", line 84, in check_openmp_support
extra_postargs=openmp_flags)
File "C:\PROGRAMDATA\ANACONDA3\lib\distutils\_msvccompiler.py", line 345, in compile
self.initialize()
File "C:\PROGRAMDATA\ANACONDA3\lib\distutils\_msvccompiler.py", line 238, in initialize
vc_env = _get_vc_env(plat_spec)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 185, in msvc14_get_vc_env
return EnvironmentInfo(plat_spec, vc_min_ver=14.0).return_env()
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 843, in __init__
self.si = SystemInfo(self.ri, vc_ver)
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 485, in __init__
self.vc_ver = vc_ver or self._find_latest_available_vc_ver()
File "C:\PROGRAMDATA\ANACONDA3\lib\site-packages\setuptools\msvc.py", line 492, in _find_latest_available_vc_ver
raise distutils.errors.DistutilsPlatformError(err)
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
----------------------------------------
Running setup.py clean for scikit-learn
Failed to build scikit-learn
Installing collected packages: scikit-learn
Found existing installation: scikit-learn 0.20.1
Uninstalling scikit-learn-0.20.1:
Failed building wheel for scikit-learn
Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\programdata\\anaconda3\\lib\\site-packages\\scikit_learn-0.20.1-py3.7.egg-info\\dependency_links.txt'
Consider using the `--user` option or check the permissions.
收到類似錯誤后,我可以按照官方網站https://scikit-learn.org/stable/install.html 的說明安裝 scikit-learn scikit-learn
如果 Python 安裝在用戶主目錄下的 AppData 文件夾結構等嵌套位置,則 pip 在達到 Windows 的默認路徑大小限制時可能無法安裝包:
Collecting scikit-learn
...
Installing collected packages: scikit-learn
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\\Users\\username\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python37\\site-packages\\sklearn\\datasets\\tests\\data\\openml\\292\\api-v1-json-data-list-data_name-australian-limit-2-data_version-1-status-deactivated.json.gz'
在這種情況下,可以使用 regedit 工具取消 Windows 注冊表中的限制:
在 Windows 開始菜單中鍵入“regedit”以啟動 regedit。
Go 到Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\FileSystem
鍵。
編輯該鍵的LongPathsEnabled
屬性的值並將其設置為 1。
重新安裝scikit-learn(忽略之前的壞安裝):
pip install --exists-action=i scikit-learn
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.