pythonimportpycharmpyc

PyCharm cannot see my newly compiled .pyc see on import


I'm using PyCharm and I have file foo.py. foo.py has a username and base64 representation of a password inside of it. I'm compiling foo.py so it's no longer readable by human eyes.

I'm running a command via the terminal

python -m py_compile foo.py

I can see the compiled .pyc file in the pychache folder named foo.cpython-39.pyc.

I remove foo.py.

When I add the line import foo, PyCharm indicates it cannot find the module.

If foo.py is retained, then of course the import line is fine.

If I copy and rename the .pyc file from the pycache folder to the root folder, calling it foo.pyc, PyCharm still indicates that it cannot find the module.

I have done this before so I know it's possible, but there is obviously a step I'm missing. Does anyone have any idea what that might be?


Solution

  • It is a cache issue or maybe a configuration issue,

    You could try to clear the cach, go File then Invalidate Caches / Restart... then Invalidate and Restart

    You can also check that the .pyc files are in the pycache directory