Python Jupyter安装line_profiler失败

2024-05-08 12:19:53 发布

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

我只找到了相关的帖子,但看起来不适用于这里。 我遵循Julyter笔记本中关于Python优化Profiling and Optimizing Jupyter Notebooks - A Comprehensive Guide的指南。在

并尝试以书面形式安装line_profiler。首先,正如在指南!pip install line_profiler中所写。我得到错误error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/。因此,我安装了从该链接下载的C++ redistributable,并重新启动了Windows10,但错误仍然存在。在

我通过Web搜索找到了这里的建议,{ A2},但是两个建议的方法都失败了,其中一个错误与C++有关。在

import sys
!{sys.executable} -m pip install line_profiler

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

^{2}$

EnvironmentNotWritableError: The current user does not have write permissions to the target environment. environment location: C:\ProgramData\Anaconda3

我尝试了conda,因为我是通过Anaconda包安装Julyter的。在本文中,我提到了不要使用sudo,因此我没有尝试以某种方式使用具有管理员权限的install。在

我能调查这个问题/我能做什么来解决这个问题?在

添加:

我可以安装“简单”的测试包,比如!pip install simplejson结果是Successfully installed simplejson-3.16.0。在

按照orangeInk的建议,我安装了Desktop development with C++建议的https://stackoverflow.com/questions/48541801/microsoft-visual-c-14-0-is-required-get-it-with-microsoft-visual-c-build-t-现在改为pip导致了几个小时的内核繁忙,然后我关闭了那本笔记本,因为我认为它不会花那么长时间。在


Tags: installpiphttpscomis错误withline
1条回答
网友
1楼 · 发布于 2024-05-08 12:19:53

首先,我同意@merv。除非绝对必要,否则您应该尽量避免混合使用pip和conda安装的软件包。在

你发布的最后一个解决方案是绝对好的。只需修复权限就可以了,不需要构建工具。在

import sys
!conda install  yes  prefix {sys.prefix} line_profiler
第二,C++重新分配和它要安装的构建工具之间有区别。对于构建工具,请转到此处https://visualstudio.microsoft.com/visual-cpp-build-tools/向下滚动一点并下载Visual Studio 2019的构建工具。(注意:我不知道现在的MS构建工具是如何工作的,但是要注意下载量可能会很大。)

(有关安装MS构建工具的更深入讨论,请参见Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualst udio.com/visual-cpp-build-tools

相关问题 更多 >