Jump to content
Geochemist's Workbench Support Forum

python script doesnt work


Helge

Recommended Posts

Hello,

I fail to run a python script which worked on a different computer and I simply cannot figure out where is the problem. Enclosed you find

  • python script
  • database 
  • settings for path variables
  • output on the command line

In case it is important: I am working from remote ("Home Office") on the computer where the executables are located. 

Many thanks,

Helge

python-problem.zip

Link to comment
Share on other sites

Hello Helge,

Thank you for providing the files for your run. I believe the path to the GWB folder is added correctly from your screenshot. A possible issue comes to mind. If you are using python 3.8+, the dll search behavior was changed from previous versions such that python no longer looks in PATH for dlls that modules might need. Please try adding the bolded part below to your python script and try rerunning. 
 
# To find the plugin
sys.path.append('c:/program files/gwb/src')
import os
os.add_dll_directory('c:\program files\gwb') 
from GWBplugin import *
 
It seems to solve the issue when I tried it on my machine (currently running python 3.10). 
 
If that didn't help to resolve the issue, could you please double check that you are using the same version of python as the GWB installed (64-bit vs 32-bit)? Are you using any Windows emulator software to run GWB? Is the GWB installed on your work machine that you're remotely connecting or on your home office machine? 
 
Hope this helps,
Jia Wang
Aqueous Solutions LLC
Link to comment
Share on other sites

Dear Jia,

thanks for the advice, it works. The beginning of the script now reads 

#!/usr/bin/env python
import os, glob, sys, string, math


# To find the plugin
sys.path.append('c:/program files/gwb/src')
os.add_dll_directory('c:/program files/gwb')


# import GWBplugin class
from GWBplugin import *

Indeed the problem didn't arise with a colleague who uses python 3.8 (I am using 3.10). 

Best regards,

Helge

Link to comment
Share on other sites

  • 1 year later...

Sorry for opening this thread again, but I am again having trouble using the python plugin. 

I call the python script from cmd-line using 

python 0293.py

Error message is that it can't find the given module (?)

I enclose the database, the script, and the env-variables. Python version is 3.10.5

I use GWB Professional, version 17.? (can't figure out where to retrieve the version number)

I know for certain that the enclosed script worked February last year. Every help appreciated. 

Best regards,

Helge

 

0293.zip

Link to comment
Share on other sites

Hello Helge,

Thank you for attaching your files. The last time we troubleshooted, it looks like you had set the environment path variable for the GWB, but env.txt doesn't show it there anymore. Has anything changed on your machine since the last time you had a successful run? One easy way to ensure that environment variables are set correctly is to have the software installer do it for you. Could you try reinstalling the software and check 'set user PATH and PYTHONPATH environment variables' in the last step?

If you continue to run into errors, please check our GWB plugin support section for explanations to some common errors:

https://www.gwb.com/plugin-Python.php#SUPPORT

If you continue to encounter issues, please let us know what you have tried so far and we will be happy to help with troubleshooting.

Best regards,
Jia

Link to comment
Share on other sites

I manually changed env variables (c:\program\user\gwb and c:\program\users\scr) and it works. I am quite sure I didn't deactivate this option upon installation, though! 

Thanks for response 🙂

Helge

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...