Christine
-
Posts
5 -
Joined
-
Last visited
Posts posted by Christine
-
-
Hi Jia,
Unfortunately I am still getting the same error. It looks it is able to find the GWBplugin.py file, but for some reason when it gets to the "initialize" stage it throws the error.
-
Hi again Jia,
My GWB was indeed the 32-bit. I have since uninstalled it, and reinstalled the 64-bit version, however I am still getting the same error. I am using sys.path.append('C:\Program Files\Gwb\src') this time (and when I tell python to print everything in sys.path, it does indeed include that folder), but I still get the same "FileNotFoundError" as above when I try to call the initialize function.
-
Hi Jia,
Thanks for the response. I am looking at my environment variables via system properties on windows and don't see anything called "PYTHONPATH".
I should say, I'm actually a Mac user running GWB on a Windows 7, 64 bit OS emulator, so I am not as well-versed in setting paths, etc on Windows. I am using the Anaconda python distribution with python version 3.8.8. I installed the 64-bit version because that was recommended for the 64 bit Windows OS.
So it seems there may be a few problems here. Where should I start?
-
I am trying to use the GWB python plugin to batch run some different models in React. I am running python through a Jupyter notebook, and am following the instructions for using the plugin here. The first three lines of my code are:
Quoteimport sys
sys.path.append('c:/Program Files (x86)/Gwb/src')
from GWBplugin import *which append the GWB src folder to my path successfully. However, in the next two lines of my code:
QuotemyPlugin = GWBplugin()
myPlugin.initialize('react')
I get the following error message:
QuoteFileNotFoundError Traceback (most recent call last)
<ipython-input-32-9a5cab2537cc> in <module>
1 myPlugin = GWBplugin()
----> 2 myPlugin.initialize('react')<ipython-input-30-287454ca2732> in initialize(self, app_name, file_name, cmds)
9
10 def initialize (self,app_name,file_name=None,cmds=None):
---> 11 return cdll.gwbplugin.c_initialize(byref(self.plugin), c_char_p(app_name), c_char_p(file_name), c_char_p(cmds))
12
13 def exec_cmd (self,uline):~\anaconda3\lib\ctypes\__init__.py in __getattr__(self, name)
449 if name[0] == '_':
450 raise AttributeError(name)
--> 451 dll = self._dlltype(name)
452 setattr(self, name, dll)
453 return dll~\anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error, winmode)
379
380 if handle is None:
--> 381 self._handle = _dlopen(self._name, mode)
382 else:
383 self._handle = handleFileNotFoundError: Could not find module 'gwbplugin' (or one of its dependencies). Try using the full path with constructor syntax.
I am not sure why I'm getting this error since I have already set my path to the GWB src folder. Any help would be appreciated!
Using the Python Plugin
in The Geochemist's Workbench
Posted
Hi Jia,
I've finally got this working with anaconda, and figured I'd share in case anyone else wants to try this and searches through these forums for help.
I uninstalled Anaconda, downloaded Python 3.8 directly from python.org and tried running the plugin (using the exact same code as above, with the DLL fix) via the command line as you suggested, but was getting the same error message (this time it just said 'the specified module could not be found'). I tested some earlier versions of Python as well (3.6 and 3.7), and got ' "errorMessage": "module 'os' has no attribute 'add_dll_directory'"' - I guess this was only added in Python 3.8, and without the add_dll_directory line I still got the "module not found" message.
The fix is to edit the system environment variables on Windows (Control Panel -> System-> Advanced System Settings-> Environment Variables). Under user variables, change the "PATH" variable to C:\Program Files\Gwb (not "PYTHONPATH", which should still be C:\Program Files\Gwb\src"). This did the trick, and now the plugin successfully runs both directly in a python terminal, and in my Jupyter notebook. The "add_dll_directory'" step is no longer necessary, either.
I am guessing since this was not the fix in your testing, it has something to do with how Python interacts with my emulator version of Windows 7. But in any case, I wouldn't have figured this out without going through these others steps you suggested first, so thank you very much for the help!