Jump to content
Geochemist's Workbench Support Forum

Import GWBplugin in Python


Recommended Posts

Dear GWB team,

In the past I have used the GWBplugin in Python using this synthax in my Python scripts:

import GWBplugin  # class
from GWBplugin import *
# Call GWB
myGWB = GWBplugin()
print ("Hello")

This now (even in my old unchanged examples) brings the error message:

Quote

"FileNotFoundError: Could not find module 'gwbplugin' (or one of its dependencies). Try using the full path with constructor syntax."

Adding the full path does not work and brings:

Quote

"    import c:\Program Files/gwb/src\GWBplugin  # class
            ^
SyntaxError: invalid syntax"

What can I do here (I am far away from beeing an Python expert), so any help is highly appreciated!

Many thanks in advance and best regards,
Frank

Link to comment
Share on other sites

Hello Frank,

I am sorry to hear you are having issues with Python. This sounds like your environment variable is not set correctly. You can set the environment variable path directly or have it done for you by rerunning your GWB installer. You can find resolutions for similar issues on our Python Plug-in Support section.

Section 7.3 Python in the GWB Reference Manual also provides the syntax to set path to the GWBplugin in your script if you did not check "Set PATH and PYTHONPATH" when you ran the installer. .

Hope this helps,
Jia Wang
Aqueous Solutions LLC

Link to comment
Share on other sites

Dear Jia,

many thanks for these hints, I will try them and hopefully can bring my scripts back to life.

Thanks and best regards,
Frank

Link to comment
Share on other sites

Dear Jia,

I did as recommended in the GWB-Pyhton support page and re-run the installer. I also checked the system environment variables, the settings there are ok. But the problem remains, somethin is wrong with the loading of the GWBplugin:

Quote

Traceback (most recent call last):

File "c:\users\fb5950\desktop\python\gwb-test.py", line 13, in <module>

from GWBplugin import *

File "C:\Program Files\Gwb\src\GWBplugin.py", line 14, in <module>

gwbdll = cdll.LoadLibrary(bin_path + 'gwbplugin')

File "C:\Users\fb5950\AppData\Local\Programs\MUEDIT~1\Python\lib\ctypes\__init__.py", line 451, in LoadLibrary

return self._dlltype(name)

File "C:\Users\fb5950\AppData\Local\Programs\MUEDIT~1\Python\lib\ctypes\__init__.py", line 373, in __init__

self._handle = _dlopen(self._name, mode)

FileNotFoundError: Could not find module 'gwbplugin' (or one of its dependencies). Try using the full path with constructor syntax.

>>>

 

---------- FINISHED ----------

exit code: 2 status: 0

I also tried to give Python the path directly via:

sys.path.append("c:/program files/gwb/src")

Same effect.

I will try it on my second device this afternoon.

Thanks and best regards,
Frank

Link to comment
Share on other sites

Hello Frank,

Thanks for checking the environment variables. The file path returned for your python installation looks a little unusual. Has your python installation changed recently or since you last successfully used the software? Some python installation (e.g. Python from Window's App store) may have security limitations and prevent it from working properly with the GWBplugin. We recommend downloading the Windows installer, either 32-bit or 64-bit depending on your GWB installation, from Python's webpage.

Here are some steps to help diagnose the issue on the python side. Can you please open the command prompt, enter 'python',  and then enter the following commands?

import os,sys
print(sys.path)
print(os.listdir('C:\\Program Files\\Gwb\\src')) 
print(os.environ['GWB_BIN_PATH'])
print(os.listdir(os.environ['GWB_BIN_PATH']))

Please let us know what you get.

Best,
Jia

Link to comment
Share on other sites

Dear Jia,

thanks for your help! The problem was within the environment variables. Since my companies computers are not maintained by the user but by the administration team, the environment variables were set to the admin account (and were labeled GWB instead of GWB_BIN_PATH). After setting this into the systemwide environment variables, it now works again.

Many many thanks and best regards,
Frank

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...