0

My script needs to run in a directory with other python files and librarys (.py,.pyd ect) but conflicts with the files, Im guessing its from the file _ctypes.pyd in the same dir as the script:

C:\Users\Guest\AppData\Local\Programs\Python\Python35-32\python.exe "C:/Program Files (x86)/Program/script.py"
Traceback (most recent call last):
  File "C:/Program Files (x86)/Program/script.py", line 3, in <module>
    import ctypes
  File "C:\Users\Guest\AppData\Local\Programs\Python\Python35-32\lib\ctypes\__init__.py", line 7, in <module>
    from _ctypes import Union, Structure, Array
ImportError: dynamic module does not define module export function (PyInit__ctypes)

Is there a way around this? The script needs to be able to run in any directory without errors

goli
  • 83
  • 1
  • 3

1 Answers1

0
import sys
sys.path.insert(0, "/path/to/your/package_or_module")

Use the code before importing any library.

Avijit Dasgupta
  • 2,055
  • 3
  • 22
  • 36