I have created a shared object file "myFile.so" that I am able to load and use via ctypes using the base anaconda environment without issue.
For example, I have no problem doing the following:
import ctypes
clibrary = ctypes.CDLL(r"C:\Users\FirstName LastName\Documents\Project\myFile.so")
clibrary.doThings(ctypes.c_int(10), ctypes.c_float(0.6))
However, when I activate a virtual environment "testEnvironment" and use the same code I get the following error:
FileNotFoundError: Could not find module 'C:\Users\FirstName LastName\Documents\Project\myFile.so' (or one of its dependencies). Try using the full path with constructor syntax.
Since the problem seems to involve the way in which anaconda environments search for things, I tried copying the value of os.environ["PATH"] from my base environment to the testEnvironemnt, but received the same error after running the code. I also tried navigating directly to the folder where the file "myFile.so" is located and running the code from there, but again no luck.
Update
The base python environment was using python version 3.8.5, while the virtual environment was using python version 3.10.6. I created a new virtual environment using python version 3.8.5 and the above code ran without issue. Therefore the problem appears to be related a change that has occurred between these python versions rather than something related to anaconda environments.
Update 2
I still have not found a way to solve the problem in version 3.10.6. However, I also tested version 3.9.15 and the code ran without issue.