Question

I use google drive application wrote a desktop application using python and everything works fine. But when I use pyinstaller to output a .exe file and run that application. A problem occurs on these lines:

if credentials is None or credentials.invalid:
  credentials = run(FLOW, storage)

The authentication page shows and I allow its access. Unlike usual, there is no response after that and I found that the .exe program exits with no reason. Anyone met this problem before? If so, how to solve it?

P.S. I traced the error now and it is as follows:

Traceback (most recent call last):
  File "<string>", line 697, in <module>
  File "<string>", line 562, in __init__
  File "build\bdist.win32\egg\oauth2client\tools.py", line 166, in run
  File "build\bdist.win32\egg\oauth2client\client.py", line 1069, in step2_exchange
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1544, in request
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1294, in _request
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 1230, in _conn_request
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 984, in connect
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/httplib2", line 80, in _ssl_wrap_socket
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/ssl", line 381, in wrap_socket
  File "USB\build\pyi.win32\USB\outPYZ1.pyz/ssl", line 141, in __init__
       ssl.SSLError: [Errno 185090050] _ssl.c:340: error:0B084002:x509 certificate rout
       ines:X509_load_cert_crl_file:system lib

I saw someone encountered the similar error http://code.google.com/p/google-api-python-client/issues/detail?id=58 but the reply said it already fixed it. I also tried the method in https://github.com/kennethreitz/requests/issues/557 but it is not working. Does anyone know how to fix it?

Was it helpful?

Solution 2

After digging a little bit, I found the solution based on solution provided by Dropbox api developer: https://forums.dropbox.com/topic.php?id=65523&replies=1#post-461457. This problem is basically caused by:

 CA_CERTS = os.path.join(os.path.dirname(os.path.abspath(__file__ )), "cacerts.txt")

__file__ is the key that causes this problem. It cannot work normally in the executable program to find the path.

Similar problem can be found here: pyinstaller seems not to find a data file

In order to solve this problem, I change the above code into this:

 CA_CERTS = os.path.join(os.path.dirname(sys.executable), "cacerts.txt")

By doing this, the .exe program will try to find cacerts.txt in the directory where .exe file is located. After compiling this into .pyc, I put cacerts.txt into .exe directory. Then the program can run normally.

OTHER TIPS

I'm guessing, but this is possible related to STDIN handling on Windows exe from pyinstaller - usually this won't be available to you, so you might have to run your own custom flow.

But you can narrow it down to either:

  1. Reading/writing from STDIN/STDOUT
  2. Starting a local web server
  3. Launching a browser

Since all those need to be performed when running a flow locally, and one of them is going wrong for you.

If you log STDERR to a text file, you will be able to see which part is crashing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top