gpt4 book ai didi

Python Jupyter 安装 line_profiler 失败

转载 作者:行者123 更新时间:2023-12-01 07:18:39 25 4
gpt4 key购买 nike

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

并尝试按照书面方式安装line_profiler。首先就像指南 !pip install line_profiler 中所写的那样。我收到错误错误:需要 Microsoft Visual C++ 14.0。使用“Microsoft Visual C++ 构建工具”获取它:https://visualstudio.microsoft.com/downloads/。因此,我安装了从该链接下载的 C++ redistributable 并重新启动了 Windows 10,但错误仍然存​​在。

然后我通过网络搜索找到并遵循这里的建议 Installing Python Packages from a Jupyter Notebook但两种建议的方法都失败了,其中一种与 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/

import sys
!conda install --yes --prefix {sys.prefix} line_profiler

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

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

可能是什么问题以及我还能采取什么措施来解决/调查该问题?

添加:

我可以安装“简单”测试包,例如!pip install simplejson导致成功安装simplejson-3.16.0

按照orangeInk回答的建议,我安装了https://stackoverflow.com/questions/48541801/microsoft-visual-中建议的使用C++进行桌面开发 c-14-0-is-required-get-it-with-microsoft-visual-c-build-t - 现在 pip 的变体导致内核繁忙几个小时,然后我合上笔记本,因为我认为不会花那么长时间。

最佳答案

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

您发布的最后一个解决方案绝对没问题。只需修复权限即可开始,无需构建工具。

import sys
!conda install --yes --prefix {sys.prefix} line_profiler

其次,C++ 可再发行组件和它希望您安装的构建工具之间存在差异。对于构建工具,请转到此处 https://visualstudio.microsoft.com/visual-cpp-build-tools/向下滚动一点并下载 Build Tools for Visual Studio 2019。(注意:我现在不知道 MS Build Tools 是如何工作的,但请注意下载可能相当大。)

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

关于Python Jupyter 安装 line_profiler 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57819526/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com