Search code examples
pythonimportcompilationpycpyd

What may be causing Python to not read .pyc or .pyd files on a new cloud server?


I've searched high and low but haven't found this question precisely asked before. I'm new to this process so the answer may turn out to be very simple.

I'm running Python in an Anaconda virtual environment model which references the Python 2.x libraries of a 32-bit software in C:\Program Data (x86). All of this is on a Windows 64-bit AWS cloud server I have just created, so this machine has no installations other than the ones I have manually added to it today. I've installed Anaconda 2--4.3.1 32-bit with Python 2.7, the software itself, and model (which houses specific versions of many Python packages).

When I open an Anaconda prompt and enter activate model and then try to Python-import any .pyc or .pyd files I need from the software, I get:

File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module cannot be found.

I am pretty certain this is not a directory issue. When I use uncompyle6 to decompile any of the .pyc files into a .py file, and place it into the same directory, the command works fine, up until the next .pyc must be imported:

File "<stdin>", line 1, in <module>
File "c:\program data (x86)\[rest of the filepath]\app.py", line 8, in <module>
   import core._services as value1
ImportError: DLL load failed: The specified module cannot be found.

^ Trying to import core._services.pyc. When I decompyle that one into a .py too, it works, but I just get the same problem with the next import.

Furthermore, when I perform this entire process on my local machine, including all the installations and the same Anaconda version and the exact same directories, everything works fine.

It seems Python on my AWS cloud server is really just having trouble reading .pycs and .pyds. uncompyle6 works that one time, but I can't do it for the .pyds, and there are hundreds of these libraries.

What may be causing Python to fail to import these .pyc files? Is it because I am using a 64-bit server with these 32-bit scripts? Could it be a "debug" version of Python, per this thread? Is it something to do with __pycache__ or cython? Could there be a security setting doing this?

My goal here is just to get Python to read the libraries so I can run things in model. Any help is appreciated.


Solution

  • It sounds like you are missing a DLL or its not saved in the appropriate location.