visit-dav / visit

VisIt - Visualization and Data Analysis for Mesh-based Scientific Data
https://visit.llnl.gov
BSD 3-Clause "New" or "Revised" License
438 stars 116 forks source link

Python Interface Error. ModuleNotFoundError: No module named 'frontend' #4648

Closed fluxlimited closed 4 years ago

fluxlimited commented 4 years ago

Describe the bug

Running VisIt 3.3.1 with Python 3.8.2 (part of a conda environment) I ran the following

import sys
sys.path.append("C:\\Users\\MyName\\LLNL\\VisIt 3.1.1\\lib\\site-packages")

from visit import *

Launch()

I get the error:

Traceback (most recent call last):
  File "c:/Users/MyName/Desktop/MyFolder/Python Scripts/test.py", line 4, in <module>
    from visit import *
  File "C:\Users\MyName\LLNL\VisIt 3.1.1\lib\site-packages\visit\__init__.py", line 29, in <module>
    from frontend import *
ModuleNotFoundError: No module named 'frontend'

To Reproduce

See above.

Expected behavior

VisIt should launch.

Attachments

N/A

Desktop

Additional context

N/A

biagas commented 4 years ago

VisIt 3.1.1 for windows was compiled with Python 2.7.14, you will need to install that version of python in order to import visit into python. If you cannot install Python 2.7, then you will need to run VisIt's cli directly in order to control it via python.

From a command prompt run '\path\to\visit.exe -cli', or use the Start menu shortcut 'Visit 3.1.1/VisIt command line interface'

We are currently working on the port to Python 3.

fluxlimited commented 4 years ago

Thank you!

fluxlimited commented 4 years ago

@biagas so I installed Python 2.7 and the Launch() command opens a visit window but quickly disappears. I tried the following

import sys
sys.path.append("C:\\Users\\MyName\\LLNL\\VisIt 3.1.1\\lib\\site-packages")

from visit import *

# Step 1: Open a database
OpenDatabase("C:\\Users\\MyName\\Desktop\\MyFolder\\MyFile.00000")

# Step 2: Add plots
AddPlot("Pseudocolor", "pressure")
AddPlot("Mesh", "quadmesh")

# Step 3: Draw the plots
DrawPlots()

and I get the error

  File "c:/Users/MyName/Desktop/MyFolder/Python Scripts/visit_test.py", line 8, in <module>
    OpenDatabase("C:\\Users\\MyName\\Desktop\\MyFolder\\MyFile.00000")
NameError: name 'OpenDatabase' is not defined

Not sure if this is installation issue or not so I am continuing this thread here.

biagas commented 4 years ago

Thanks for the info, let me try a few things and get back with you.

biagas commented 4 years ago

In your scenario, you need to call 'Launch()' before using any Visit commands.

Also, please be aware, if you enabled parallel when you installed VisIt, then the OpenDatabase call will prompt VisIt to open a dialog asking you to choose between the serial and parallel engines. This dialog may be hidden behind your python terminal window.

fluxlimited commented 4 years ago

I added Launch(). A VisIt window is created and I get the prompt to choose between serial and parallel engines. I choose serial and then VisIt exits. Nothing is drawn. I see no error in the Python interpreter either. The plot works in the VisIt GUI.

biagas commented 4 years ago

Can you try opening one of the sample files included with the VisIt installation, say \path\to\visit 3.1.1\data\globe.silo, create Pseudocolor plot of "u", and add arguments before Launch so that VisIt will create debug logs.

AddArgument("-debug")
AddArgument("5")
Launch()
OpenDatabase("C:\\path\\to\\visit 3.1.1\\data\\globe.silo")
AddPlot("Pseudocolor", "u")
DrawPlots()

The generated log files will be in your Documents directory, in a VisIt folder. If Visit succeeds with this, then try again with your data. You can attach the zipped log files here.

fluxlimited commented 4 years ago

The logs are below. Same thing happens with the sample files. VisIt pops open for a second after selecting serial and then disappears.

visit_logs.zip

biagas commented 4 years ago

Sorry, but the log files aren't indicating what's going wrong. Can you try again, but using visit's cli directly instead of importing from python. Launch a command prompt and run:

\path\to\visit 3.1.1\visit.exe -cli -debug 5

Then enter the same visit commands as before starting from 'OpenDatabase'. There should be similar log files as before, with the additions of logs from 'cli' process.

You might want to clear out the old .vlog files from your Documents/VisIt directory first.

fluxlimited commented 4 years ago

Using the cli directly allows the plot window to stay up and I am able to manipulate it as expected. Logs are below.

visit_cli_logs.zip

biagas commented 4 years ago

So, it's a problem while importing VisIt, not directly the cli. Are you willing to use VisIt's cli instead of importing to python?

I've tried importing VisIt 3.1.1 into python on two Windows 10 systems: one my normal develop machine (using Python 2.7.14) , and another a non-development machine(with Python 2.7.18 installed). In both cases, I had no problems importing and using VisIt from python. Unfortunately, that make is hard for me to diagnose your problem.

Perhaps I am not understanding something important about your system setup, or the steps you've taken. What is the full version of python you are using? How do you launch it. Anything out of the ordinary in your environment or path that would interfere with python 2.7?

fluxlimited commented 4 years ago

@biagas seems to be something with VS Code and not VisIt. I am running Python 2.7.18 from a conda environment and using VS Code as my IDE. I installed IDLE in the conda environment, ran it from there and it works as expected. Sorry for the runaround. I really appreciate your help.

biagas commented 4 years ago

You are welcome, glad you found a way to get things working.

bharath-kumarn commented 3 years ago

i solved this problem by upgrade python pip:

pip install --upgrade pip pip install -U PyMuPDF

brugger1 commented 3 years ago

Thanks for passing that along.