yappi does not import

I’m trying to use Yappi. I installed it successfully with pip. When I try to import it to my Python program, I receive an error message that _yappi cannot be found. I’ve had no luck finding this file. Any help would be appreciated. Thanks.

If you intended to use _yappi and it’s actually yappi , then this installation command should work.

pip install yappi

or

pip install yappi

Just now tried with example:
import yappi

def a():
for _ in range(10000000):
pass

yappi.set_clock_type(“cpu”)
yappi.start()
a()

yappi.get_func_stats().print_all()
yappi.get_thread_stats().print_all()

Thanks for the reply. The file _yappi is imported by yappi but since it does not exist, I get an error message. I never heard of the file _yappi before. I only learned about it when I received the error message.
FYI, I did try the statements you suggested, but since import yappi is the first, I never get anywhere.

It’s ordinary that packages like this have some internal implementation details in another file with a leading underscore. If yappi is found but _yappi is not, it can mean that something went wrong with the installation. I checked the project GitHub and I can see that _yappi comes from C code, so maybe there was a problem compiling this code when you tried to install the module? This should normally cause the entire installation to fail, but there could be something strange about how the installation is set up.

Diagnosing the problem properly will require more information, such as:

  • A complete stack trace for the error - copy and paste, starting from the line that says Traceback (most recent call last): all the way to the end, and format it here like multi-line code (as described in the pinned thread).

  • Complete, concrete steps taken for the installation

  • The result of which pip and which python (assuming that you use the command pip to run Pip and python to run Python)

Better yet if you can find a way to reproduce the problem, in a new virtual environment.