2

I'm attempting to run a profiling process on my website, per the discussion here, but have run into this error. Here's the full stack trace:

C:\Users\Alex\Anaconda3\envs\mysite\python.exe C:/Users/Alex/Desktop/mysite/profile.py
Traceback (most recent call last):
  File "C:/Users/Alex/Desktop/mysite/profile.py", line 6, in <module>
    app = ProfilerMiddleware(app)
  File "C:\Users\Alex\Anaconda3\envs\mysite\lib\site-packages\werkzeug\contrib\profiler.py", line 80, in __init__
    raise RuntimeError('the profiler is not available because '
RuntimeError: the profiler is not available because profile or pstat is not installed.

At first I assumed that this is one of those Windows errors, and I tried doing the same thing on my Mac. Same error.

Hmm. I found the responsible import statements in the werkzeug code:

try:
    try:
        from cProfile import Profile
    except ImportError:
        from profile import Profile
    from pstats import Stats
    available = True
except ImportError:
    available = False

This causes the failure on later on, on line 79:

    if not available:
        raise RuntimeError('the profiler is not available because '
                           'profile or pstat is not installed.')

So I guess that means I'm missing one of these modules? But they're core Python modules AFAIK!

I popped open a IPython console, booted into the responsible conda virtual environment, and sure enough:

enter image description here

What's going on?

Aleksey Bilogur
  • 3,686
  • 3
  • 30
  • 57

0 Answers0