1

I've found on SO only that related post but looks it does not apply here. I'm following guide on Python optimization Profiling and Optimizing Jupyter Notebooks - A Comprehensive Guide in Julyter notebook.

And tried as written install line_profiler. First just as was written in the guide !pip install line_profiler. I got error error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/. So I've installed C++ redistributable downloaded from that link and restarted Windows 10 but the error persisted.

Then I've found by web search and to follow advice from here Installing Python Packages from a Jupyter Notebook but both advised ways failed, one with same error about 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

I've tried conda as I've installed Julyter by Anaconda package install. In the article I've mentioned it is advised against using sudo so I have not tried to somehow use install with admin privileges.

What could be the problem and what else can I do to fix/investigate the issue?

ADDED:

I can install "simple" test packages, like !pip install simplejson resulted in Successfully installed simplejson-3.16.0.

Following advice in answer by orangeInk I installed Desktop development with C++ advised in https://stackoverflow.com/questions/48541801/microsoft-visual-c-14-0-is-required-get-it-with-microsoft-visual-c-build-t - now variant with pip resulted in several hours of kernel busyness, then I closed that notebook as I thought it should not take that long.

Alex Martian
  • 3,423
  • 7
  • 36
  • 71
  • I'd recommend against using `pip` in a Conda env unless absolutely necessary (see "[*Using Pip in a Conda Environment*](https://www.anaconda.com/using-pip-in-a-conda-environment/)"). Also, do you really need to install from within Jupyter? It seems like an unnecessary complication to manipulate the environment while it is active. E.g., is the Jupyter server executing as a different user? – merv Sep 06 '19 at 15:57
  • @merv, "Also, do you really need to install from within Jupyter? It seems like an unnecessary complication to manipulate the environment while it is active." -maybe, but `pip` is not found when invoked from command prompt, it would be a complication to add it to path when it is working from notebook - as least I thought so. "E.g., is the Jupyter server executing as a different user" - I just installed Anaconda on Windows 10 and starting Jupyter from menu, does it answer the question? – Alex Martian Sep 09 '19 at 06:52

1 Answers1

1

First of all, I agree with @merv. You really should try to avoid mixing pip and conda installed packages unless absolutely necessary.

The last solution you posted is absolutely fine. Just fix the permissions and you're good to go, no need for Build Tools.

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

Secondly, there's a difference between the C++ redistributable and the Build Tools it wants you to install. For the Build Tools go here https://visualstudio.microsoft.com/visual-cpp-build-tools/ scroll down a little and download Build Tools for Visual Studio 2019. (Note: I don't know how MS Build Tools work these days, but beware that the download might be rather large.)

(For a more indepth discussion on installing MS Build Tools, see Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualst udio.com/visual-cpp-build-tools)

orangeInk
  • 1,360
  • 8
  • 16
  • thank you for Build Tools explanation. however I have not succeeded still, please see ADDED to the question. – Alex Martian Sep 09 '19 at 14:30
  • 1
    The reason you can install simple packages is that those simple packages don't require any compilation (which is what you need the Build Tools for). When you pip-install packages that require some compilation then it might actually take some time depending on the hardware it's running on (though several hours, as you said, should not be normal). Using conda install - instead of pip - means you'll install precompiled packages that don't need any compilation/Build Tools. I don't know why compilation takes that long for you. – orangeInk Sep 11 '19 at 12:06