module not loading in .py file using netgen in terminal
- swanket
- Topic Author
- New Member
Less
More
2 years 4 months ago #4437
by swanket
module not loading in .py file using netgen in terminal was created by swanket
HI,
I am new to ngsolve and I recently received a model from a colleague that uses ngsolve. After installing using pip a demo of the model should be usable by simply saying "netgen demo.py" in terminal. demo.py is a python file with the code to run the model and calls a module within it. That module is in the same folder as demo.py and appears usable in vscode when I am reading the code, however when I run this line in terminal I get the error: "ModuleNotFoundError: No module named 'magmaxisym'". If I run the code in vscode this is not an issue, however I don't have access to the actual geometry so I need to be using ngsolve.
Do you have any suggestions on how to fix this issue? I am using the pip install on a Mac.
Thanks
I am new to ngsolve and I recently received a model from a colleague that uses ngsolve. After installing using pip a demo of the model should be usable by simply saying "netgen demo.py" in terminal. demo.py is a python file with the code to run the model and calls a module within it. That module is in the same folder as demo.py and appears usable in vscode when I am reading the code, however when I run this line in terminal I get the error: "ModuleNotFoundError: No module named 'magmaxisym'". If I run the code in vscode this is not an issue, however I don't have access to the actual geometry so I need to be using ngsolve.
Do you have any suggestions on how to fix this issue? I am using the pip install on a Mac.
Thanks
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
2 years 4 months ago #4440
by christopher
Replied by christopher on topic module not loading in .py file using netgen in terminal
Hi, did you also get an additional file "magmaxisym.py" from your colleague? You need to add the folder of that file to your PYTHONPATH environment variable. you can also run the code in visual studio and add
at the top of the file to open the gui from python.
Code:
import netgen.gui
- swanket
- Topic Author
- New Member
Less
More
2 years 4 months ago #4443
by swanket
Replied by swanket on topic module not loading in .py file using netgen in terminal
So magmaxiym is a subfolder in the same folder as demo.py. In the magmaxiysm subfolder there is a _init_.py file which as I understand it tells python to treat magmaxiysm as a module. So I believe they are already on the same path but I still have this issue.
- christopher
- Offline
- Administrator
Less
More
- Thank you received: 101
2 years 4 months ago #4445
by christopher
Replied by christopher on topic module not loading in .py file using netgen in terminal
You need to add "." to your PYTHONPATH environment variable then.
Time to create page: 0.097 seconds