I think the description is a little bit confusing, no? Let’s do that in action and see how it works. By doing this, the virtual environment launch script will configure the path (I mean PYTHONPATH) to point to the installed packages of the environment, and we will be able to use them inside our PvPython automation script. So, as I said, the solution is a little bit different from the initial idea: we need to activate a virtual environment while we are inside Python (in this case, inside PvPython). ![]() So, it means if you run PvPython inside a virtual environment, it cannot see and use the installed packages because it is NOT the interpreter the virtual environment is configured for. When you run Python inside a virtual environment, you run the interpreter that is installed inside the virtual environment. I should say that your solution is more or less correct, but it needs a major rearrangement. You may think to yourself that the solution is quite obvious and simple: create a Python virtual environment (for example, using conda or venv) and execute PvPtyhon inside it. Now, the problem we want to discuss is the opposite of this one: we cannot use installed packages (like pandas or matplotlib) in PvPython, a scenario that can be very helpful in different applications. This doesn’t give you an error, but if you execute the statement in your local installation of Python, you will face the famous ModuleNotFoundError. To give it a try, open a terminal and type pvpython and then from paraview.simple import *. ParaView comes with its own Python intrepreter, in which you can easily access ParaView Python package. But, since this solution is not elaborated and may be difficult to follow, I implement it in this post the way I did it for myself. After trying various techniques in Windows and Linux, my conclusion is that the best solution to this problem is the one suggested here. ![]() I came across a couple of scenarios in which I needed to call a couple of packages inside PvPython, the Python client of ParaView, which allows us to automate ParaView tasks (you may take a look at this automation example to see how PvPython works). ![]() Use and import Python packages and modules inside ParaView (PvPython)
0 Comments
Leave a Reply. |