我无法在Windows10命令提示符上安装sklearn、numpy和scipy,以便在Python3.6上使用

2024-03-02 21:29:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经正确安装了python3.6,并一直在处理Eclipse。但我不能用图书馆。每次导入它们时都会收到一条错误消息:

Traceback (most recent call last):
  File "C:\Users\gilbe\eclipse-workspace\python3.6\BeginnerFiles\Irisdataset", line 1, in <module>
    from sklearn import datasets
ModuleNotFoundError: No module named 'sklearn'`

当我尝试安装sklearn、numpy和scipy时,我在Windows命令提示符中输入以下内容:

^{pr2}$

但是,我每次都会收到一条错误消息。例如:

C:\Program Files (x86)\Python36-32\Scripts>pip install sklearn
Collecting sklearn
  Using cached https://files.pythonhosted.org/packages/1e/7a/dbb3be0ce9bd5c8b7e3d87328e79063f8b263b2b1bfa4774cb1147bfcd3f/sklearn-0.0.tar.gz
Collecting scikit-learn (from sklearn)
  Using cached https://files.pythonhosted.org/packages/87/b7/0e7f5c0cf765cf4e1924c068e7b2e1708c93ebffde9302a57ea8f26619e9/scikit_learn-0.19.1-cp36-cp36m-win32.whl
Installing collected packages: scikit-learn, sklearn
Exception:
Traceback (most recent call last):
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_set.py", line 784, in install
    **kwargs
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_install.py", line 851, in install
    self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
    isolated=self.isolated,
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
    clobber(source, lib_dir, True)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\wheel.py", line 316, in clobber
    ensure_dir(destdir)
  File "c:\program files (x86)\python36-32\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
    os.makedirs(path)
  File "c:\program files (x86)\python36-32\lib\os.py", line 220, in makedirs
    mkdir(name, mode)
PermissionError: [WinError 5] Access is denied: 'c:\\program files (x86)\\python36-32\\Lib\\site-packages\\scikit_learn-0.19.1.dist-info'
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

此外,当我尝试使用上面建议的命令升级pip命令时,也会收到一条错误消息:

C:\Program Files (x86)\Python36-32\Scripts>python -m pip install --upgrade pip
Collecting pip
  Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
Exception:
Traceback (most recent call last):
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\basecommand.py", line 215, in main
    status = self.run(options, args)
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\commands\install.py", line 342, in run
    prefix=options.prefix_path,
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\req\req_set.py", line 778, in install
    requirement.uninstall(auto_confirm=True)
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\req\req_install.py", line 754, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "C:\Program Files\Inkscape\python\lib\site-packages\pip\utils\__init__.py", line 267, in renames
    shutil.move(old, new)
  File "C:\Program Files\Inkscape\python\lib\shutil.py", line 303, in move
    os.unlink(src)
WindowsError: [Error 5] Access is denied: 'c:\\program files\\inkscape\\python\\lib\\site-packages\\pip-9.0.1.dist-info\\description.rst'
You are using pip version 9.0.1, however version 10.0.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

我真正的问题是如何解决这些问题,并正确安装这些库,我花了一整天的时间试图用不同的方法来解决这个问题,包括:从Eclipse内部安装库,通过Window>;Preferences>;Preferences>;Python interprelator>;install with pip ,卸载并重新安装Python,尝试使用easy_install <package>命令。在

请帮忙。在


Tags: installpipinpylibpackageslinesite
1条回答
网友
1楼 · 发布于 2024-03-02 21:29:06

右击屏幕左下角的windows按钮。 然后转到“Windows PowerShell(管理)”。 在那里你尝试你的pip安装。它肯定会起作用的。我想你没有管理员权限这就是为什么你看到了。在

PermissionError: [WinError 5] Access is denied

只需以管理员身份打开命令用户。希望这有帮助。在

相关问题 更多 >