Search code examples
pythonpy2exe

No module named 'oauthlib.oauth1.rfc5849.endpoints.resource' after py2exe the code (python)


I'm trying to get my script to exe using py2exe. There is no error when converting the script but when I try to run main.exe I get the following error:

    Traceback (most recent call last):
  File "main.py", line 1, in <module>
  File "gspread\__init__.pyc", line 16, in <module>
  File "gspread\auth.pyc", line 14, in <module>
  File "google_auth_oauthlib\__init__.pyc", line 21, in <module>
  File "google_auth_oauthlib\interactive.pyc", line 24, in <module>
  File "google_auth_oauthlib\flow.pyc", line 69, in <module>
  File "google_auth_oauthlib\helpers.pyc", line 28, in <module>
  File "requests_oauthlib\__init__.pyc", line 3, in <module>
  File "requests_oauthlib\oauth1_auth.pyc", line 7, in <module>
  File "oauthlib\oauth1\__init__.pyc", line 21, in <module>
  File "oauthlib\oauth1\rfc5849\endpoints\__init__.pyc", line 5, in <module>
ModuleNotFoundError: No module named 'oauthlib.oauth1.rfc5849.endpoints.resource'

I don't seem to be able to find said module nor install it with pip. Sorry if the fix is actually easy, I'm pretty dumb.


Solution

  • You can just use PyInstaller which will turn your code into a .exe file in the folder dist

    install:

    py -m pip install pyinstaller
    

    After installing

    cd [file path]
    

    then,

    py -m PyInstaller --onefile [script name].py