无法用gspread从python中生成工作exe。

时间:2022-12-12 18:02:57

I have a script, which uses gspread for manupilating with Google Drive data. And I want to create a simple executable in Windows. But yet no luck.

我有一个脚本,它使用gspread来处理谷歌驱动数据。我想在Windows中创建一个简单的可执行文件。但是没有运气。

Note

请注意

  • Python 3.4
  • Python 3.4
  • Windows XP
  • Windows XP

What I've tried so far:

到目前为止我所尝试的:

  • PyInstaller 3.0
  • PyInstaller 3.0
  • py2exe 0.9.9.2
  • py2exe 0.9.9.2
  • cx_Freeze
  • cx_Freeze

  1. PyInstaller

    PyInstaller

    Goes to the step 60020 INFO: Looking for ctypes DLLs and then

    到步骤60020信息:寻找ctype dll,然后。

    blah-blah-blah...

    如此等等……

      File "C:\Python34\lib\ntpath.py", line 246, in basename
        return split(p)[1]
      File "C:\Python34\lib\ntpath.py", line 217, in split
        d, p = splitdrive(p)
      File "C:\Python34\lib\ntpath.py", line 161, in splitdrive
        normp = p.replace(_get_altsep(p), sep)
    AttributeError: 'tuple' object has no attribute 'replace'
    

  1. py2exe
  2. py2exe

Setup.py (configuration took here)

设置。py(配置)

from distutils.core import setup
import py2exe, sys, os

sys.setrecursionlimit(5000)
sys.argv.append('py2exe')

setup(
    options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
    windows = [{'script': "main.py"}],
    zipfile = None,
)
  • Before I added sys.setrecursionlimit(5000) I was getting RuntimeError: Maximum recursion depth exceeded.

    在我添加sys.setrecursionlimit(5000)之前,我得到了RuntimeError:超过了最大递归深度。

  • Added sys.setrecursionlimit(5000) and RuntimeError: maximum recursion depth exceeded in comparison

    添加sys.setrecursionlimit(5000)和运行时错误:最大递归深度超过了比较。

Error is with mf3 file as here, so I added "excludes":["six.moves.urllib.parse"] but error is the same.

错误与mf3文件一样,所以我添加了“排除”:[“6 .moves.urllib”。但错误是一样的。


  1. Cx_Freeze This was the closest to success. Even created exe. But there's a problem with cacert with getting [Errno 2] No such file or directory I've tried all methods from here and here here, copied cacerts.txt, cacert.pem but still [Errno 2] No such file or directory
  2. Cx_Freeze是最接近成功的。甚至创造了exe。但是有一个问题,cacert没有这样的文件或目录,我尝试了所有的方法从这里和这里,复制了cacerts。txt,cacert。pem但是仍然[Errno 2]没有这样的文件或目录。

Here is a code of setup.py:

下面是一段setup.py的代码:

import sys
from cx_Freeze import setup, Executable
import requests.certs

includefiles = ['key.json', (requests.certs.where(),'cacert.pem')]
includes = []
excludes = []
icon = None
base = None
if (sys.platform == "win32"):
    base = "Win32GUI"

setup(
    name = 'Scraper',
    version = '1.0',

    author = 'GriMel',
    author_email = 'GriefMontana@gmail.com',
    options = {'build_exe': {'excludes':excludes,
                             'include_files':includefiles,
                             'icon' : icon}},
    executables = [Executable('main.py')],
    )

Looking forward to you help.

期待你的帮助。

1 个解决方案

#1


2  

The actual answer - here So, step by step

实际的答案是,一步一步来。

  1. Go to C:\Python34\Lib\site-packages\httplib2
  2. 转到C:\ Python34 \ Lib \网站\ httplib2
  3. Edit init.py
  4. 编辑init.py
  5. Replace
  6. 取代

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

CA_CERTS = os.path.join(os.path.dirname(os.path。abspath(__file__)),“cacerts.txt”)

by

通过

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

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

  1. Run cx_freeze script
  2. 运行cx_freeze脚本
  3. Search for cacerts.txt and cacert.pem (in my case C:\Python34\Lib\site-packages\certifi and C:\Python34\Lib\site-packages\httplib2
  4. 寻找除。txt和cacert。pem(在我的例子中是C:\Python34\Lib\site-packages\ fi和C:\Python34\Lib\site-package \httplib2)。
  5. Copy cacerts.txt and cacert.pem to the folder with exe file.
  6. 除副本。txt和cacert。pem到文件夹的exe文件。
  7. PROFIT
  8. 利润

At least exe, made by cx_freeze now works.

至少exe是由cx_freeze完成的。

#1


2  

The actual answer - here So, step by step

实际的答案是,一步一步来。

  1. Go to C:\Python34\Lib\site-packages\httplib2
  2. 转到C:\ Python34 \ Lib \网站\ httplib2
  3. Edit init.py
  4. 编辑init.py
  5. Replace
  6. 取代

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

CA_CERTS = os.path.join(os.path.dirname(os.path。abspath(__file__)),“cacerts.txt”)

by

通过

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

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

  1. Run cx_freeze script
  2. 运行cx_freeze脚本
  3. Search for cacerts.txt and cacert.pem (in my case C:\Python34\Lib\site-packages\certifi and C:\Python34\Lib\site-packages\httplib2
  4. 寻找除。txt和cacert。pem(在我的例子中是C:\Python34\Lib\site-packages\ fi和C:\Python34\Lib\site-package \httplib2)。
  5. Copy cacerts.txt and cacert.pem to the folder with exe file.
  6. 除副本。txt和cacert。pem到文件夹的exe文件。
  7. PROFIT
  8. 利润

At least exe, made by cx_freeze now works.

至少exe是由cx_freeze完成的。