OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

Python subprocess function unable to load library

  • Thread starter Thread starter rwal
  • Start date Start date
R

rwal

Guest
I am trying to execute a Java jar file via a subprocess.run() function in Python. When I execute the jar file via Java as normally performed a necessary library is found. In this case, the library is the netCDF library. However, when I use the subprocess function, the library is not found.

Even when I explicitly tell the subprocess function to look to the netcdf directory, the library is still not found. I perform the call like this:

Code:
java_env = dict(os.environ)
java_env['PATH'] = f'{java_env["PATH"]};C:\\Program Files\\netCDF 4.9.2\\bin'

result = subprocess.run(
         ['java', '-jar', jar_path],
         capture_output = True,
         text = True,
         env=java_env)

The goal of the Python routine is to call a Java jar that writes out a netCDF file. I expected the library to be found, and a netCDF file to be written out to disk. I receive the following error when running the Python routine:

Code:
[main] WARN serverStartup - Nc4Iosp: NetCDF-4 C library not present (jna_path='null', libname='netcdf').
java.lang.UnsatisfiedLinkError: Unable to load library 'netcdf':
The specified procedure could not be found.

The specified procedure could not be found.

The specified module could not be found.

Native library (win32-x86-64/netcdf.dll) not found in resource path (C:/Users/rwal/projects/target/AddLightningLayer.jar)

I also ensured that the netcdf library is in my Windows Path variable. It is necessary to use Java because I need to use an API that is written in Java. Unfortunately, there is no Python equivalent to the Java based API.

I'm using Windows 10, Python 3.10.4, and JDK 17.

Thanks for your help.
<p>I am trying to execute a Java jar file via a subprocess.run() function in Python. When I execute the jar file via Java as normally performed a necessary library is found. In this case, the library is the netCDF library. However, when I use the subprocess function, the library is not found.</p>
<p>Even when I explicitly tell the subprocess function to look to the netcdf directory, the library is still not found. I perform the call like this:</p>
<pre><code>java_env = dict(os.environ)
java_env['PATH'] = f'{java_env["PATH"]};C:\\Program Files\\netCDF 4.9.2\\bin'

result = subprocess.run(
['java', '-jar', jar_path],
capture_output = True,
text = True,
env=java_env)
</code></pre>
<p>The goal of the Python routine is to call a Java jar that writes out a netCDF file. I expected the library to be found, and a netCDF file to be written out to disk. I receive the following error when running the Python routine:</p>
<pre><code>[main] WARN serverStartup - Nc4Iosp: NetCDF-4 C library not present (jna_path='null', libname='netcdf').
java.lang.UnsatisfiedLinkError: Unable to load library 'netcdf':
The specified procedure could not be found.

The specified procedure could not be found.

The specified module could not be found.

Native library (win32-x86-64/netcdf.dll) not found in resource path (C:/Users/rwal/projects/target/AddLightningLayer.jar)
</code></pre>
<p>I also ensured that the netcdf library is in my Windows Path variable. It is necessary to use Java because I need to use an API that is written in Java. Unfortunately, there is no Python equivalent to the Java based API.</p>
<p>I'm using Windows 10, Python 3.10.4, and JDK 17.</p>
<p>Thanks for your help.</p>
 

Latest posts

Top