'ValueError: Image generation requires the psutil package. Install using pip: $ pip install psutil yet requirement already satisfied?

I am trying to save a plotly static graph using the following command:

graph.write_image("test.png")

However I get the following error:

ValueError: Image generation requires the psutil package.

Install using pip:
$ pip install psutil

However I have already done this once and receive the following trackback upon trying to install again when I have the following version of psutil

WARNING: Ignoring invalid distribution -ythonnet (c:\users\gerard\projects\venv\lib\site-packages)
WARNING: Ignoring invalid distribution -ythonnet (c:\users\gerard\projects\venv\lib\site-packages)
Requirement already satisfied: psutil in c:\users\gerard\projects\venv\lib\site-packages (5.8.0)
WARNING: Ignoring invalid distribution -ythonnet (c:\users\gerard\projects\venv\lib\site-packages)
WARNING: Ignoring invalid distribution -ythonnet (c:\users\gerard\projects\venv\lib\site-packages)
WARNING: Ignoring invalid distribution -ythonnet (c:\users\gerard\projects\venv\lib\site-packages)

psutil==5.8.0

The ValueError persists everytime. Does anyone understand this or know how I can go about debugging?

Thanks.



Solution 1:[1]

You could solve this by first ensuring you have orca installed as the engine for saving the image in plotly, instead of the default kaleido. If not, this can be installed using bash:

conda install -c conda-forge orca

Next save the image with the following command graph.write_image("test.png", engine = 'orca'). In case you still get an error, specify the location of orca on your machine in your script. You can find the location by running which orca in bash. Then copy the found path in your python script as follows:

plotly.io.orca.config.executable = '/path/to/orca'
plotly.io.orca.config.save()

Solution 2:[2]

You can try with deleting -ythonnet or psutil folder from directory c:\users\gerard\projects\venv\lib\site-packages. If that didn't help try with new virtual environment.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Stijn
Solution 2 Dysio