Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyInstaller和Google Vision-转换时出错_Python_Python Import_Pyinstaller_Google Cloud Vision - Fatal编程技术网

Python PyInstaller和Google Vision-转换时出错

Python PyInstaller和Google Vision-转换时出错,python,python-import,pyinstaller,google-cloud-vision,Python,Python Import,Pyinstaller,Google Cloud Vision,我使用Google Vision编写了带有GUI的简单Python脚本,用于扫描照片中的笔迹。 想法是将代码导入可执行程序,这样我的朋友就可以在他的windows PC上使用这个程序 我试图通过auto-py-to-exe将这段代码导入到.exe,但我不断收到错误,其中大多数都是与django相关的导入 是否可以将此脚本转换为.exe 这是我的脚本代码: from google.cloud import vision from google.cloud.vision import types i

我使用Google Vision编写了带有GUI的简单Python脚本,用于扫描照片中的笔迹。 想法是将代码导入可执行程序,这样我的朋友就可以在他的windows PC上使用这个程序

我试图通过auto-py-to-exe将这段代码导入到.exe,但我不断收到错误,其中大多数都是与django相关的导入

是否可以将此脚本转换为.exe

这是我的脚本代码:

from google.cloud import vision
from google.cloud.vision import types
import os
import io

execution_path = os.getcwd()
os.environ['GOOGLE_APPLICATION_CREDENTIALS']=r'XXXXXXXXXXXX.json'

dest = ''

def OCR():
    client = vision.ImageAnnotatorClient()
    path = dest
    image_file = io.open(path,'rb').read()
    image1 = vision.types.Image(content = image_file)
    response = client.text_detection(image = image1)
    global doc_text
    doc_text = response.full_text_annotation.text
    print(doc_text)
 


from PyQt5 import uic
import sys
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtWidgets import QApplication, QWidget, QInputDialog, QLineEdit, QFileDialog
from PyQt5.QtGui import QIcon

class Ui(QtWidgets.QMainWindow):

    def __init__(self):
        super(Ui, self).__init__()
        uic.loadUi('gui.ui', self)
        self.show()
        self.openb.clicked.connect(self.openFileNameDialog)
        self.readb.clicked.connect(self.reading)
            
        
    def openFileNameDialog(self):
        options = QFileDialog.Options()
        fileName, _ = QFileDialog.getOpenFileName(self,"QFileDialog.getOpenFileName()", "","All Files (*);;Python Files (*.py)", options=options)
        global dest
        dest = fileName
        print(dest)
        if fileName:
            #print(fileName)
            self.pic.setPixmap(QtGui.QPixmap(fileName))
            
        
            
    def reading(self):
        OCR()
        self.result.setText(doc_text)
        
app = QtWidgets.QApplication(sys.argv)
window = Ui()
app.exec_()
这是pyinstaller的输出

Running auto-py-to-exe v2.7.6
Building directory: C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny
Provided command: pyinstaller --noconfirm --onedir --console  "C:/label reader/label_reader.py"
Recursion Limit is set to 5000
Executing: pyinstaller --noconfirm --onedir --console C:/label reader/label_reader.py --distpath C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny\application --workpath C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny\build --specpath C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny

93640 INFO: PyInstaller: 3.6
93644 INFO: Python: 3.7.7
93647 INFO: Platform: Windows-10-10.0.17763-SP0
93651 INFO: wrote C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny\label_reader.spec
93657 INFO: UPX is not available.
93661 INFO: Extending PYTHONPATH with paths
['C:\\label reader', 'C:\\Users\\mukanrom\\AppData\\Local\\Temp\\tmp_9eu06ny']
93665 INFO: checking Analysis
93668 INFO: Building Analysis because Analysis-00.toc is non existent
93672 INFO: Initializing module dependency graph...
93683 INFO: Caching module graph hooks...
93695 INFO: Analyzing base_library.zip ...
95908 INFO: Processing pre-find module path hook   distutils
95913 INFO: distutils: retargeting to non-venv dir 'c:\\documents\\wpy64-3770\\python-3.7.7.amd64\\lib'
97515 INFO: Caching module dependency graph...
97607 INFO: running Analysis Analysis-00.toc
97628 INFO: Adding Microsoft.Windows.Common-Controls to dependent assemblies of final executable
  required by c:\documents\wpy64-3770\python-3.7.7.amd64\python.exe
97700 INFO: Analyzing C:\label reader\label_reader.py
108983 INFO: Processing pre-safe import module hook   setuptools.extern.six.moves
109942 INFO: Processing pre-find module path hook   site
109948 INFO: site: retargeting to fake-dir 'c:\\documents\\wpy64-3770\\python-3.7.7.amd64\\lib\\site-packages\\PyInstaller\\fake-modules'
124233 INFO: Processing pre-safe import module hook   six.moves
134498 INFO: Processing pre-safe import module hook   urllib3.packages.six.moves
136163 INFO: Processing pre-find module path hook   PyQt5.uic.port_v3
136278 INFO: Processing pre-find module path hook   PyQt5.uic.port_v2
136587 INFO: Processing module hooks...
136591 INFO: Loading module hook "hook-certifi.py"...
136596 INFO: Loading module hook "hook-cryptography.py"...
136921 INFO: Loading module hook "hook-distutils.py"...
136926 INFO: Loading module hook "hook-django.core.cache.py"...
137107 INFO: Loading module hook "hook-django.core.mail.py"...
137158 INFO: Loading module hook "hook-django.core.management.py"...
137178 INFO: Import to be excluded not found: 'IPython'
137184 INFO: Excluding import 'tkinter'
137192 INFO: Import to be excluded not found: 'matplotlib'
137195 INFO: Loading module hook "hook-django.db.backends.py"...
138715 WARNING: Hidden import "django.db.backends.__pycache__.base" not found!
138718 INFO: Loading module hook "hook-django.py"...
140567 INFO: Determining a mapping of distributions to packages...
242008 INFO: Packages required by django:
['asgiref', 'sqlparse', 'pytz']
259593 INFO: Loading module hook "hook-docutils.py"...
262424 INFO: Loading module hook "hook-encodings.py"...
262547 INFO: Loading module hook "hook-gevent.py"...
262852 WARNING: Unable to find package for requirement zope.event from package gevent.
262857 WARNING: Unable to find package for requirement zope.interface from package gevent.
262860 WARNING: Unable to find package for requirement greenlet from package gevent.
262869 INFO: Packages required by gevent:
['cffi', 'setuptools']
264109 INFO: Loading module hook "hook-google.api.py"...
264116 INFO: Loading module hook "hook-google.api_core.py"...
264121 INFO: Loading module hook "hook-google.cloud.py"...
An error occurred while packaging
Traceback (most recent call last):
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\auto_py_to_exe\packaging.py", line 131, in package
    run_pyinstaller()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\__main__.py", line 114, in run
    run_build(pyi_config, spec_file, **vars(args))
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\__main__.py", line 65, in run_build
    PyInstaller.building.build_main.main(pyi_config, spec_file, **kwargs)
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 734, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 681, in build
    exec(code, spec_namespace)
  File "C:\Users\mukanrom\AppData\Local\Temp\tmp_9eu06ny\label_reader.spec", line 17, in <module>
    noarchive=False)
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 244, in __init__
    self.__postinit__()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\building\datastruct.py", line 160, in __postinit__
    self.assemble()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\building\build_main.py", line 422, in assemble
    self.graph.process_post_graph_hooks()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\depend\analysis.py", line 311, in process_post_graph_hooks
    module_hook.post_graph()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\depend\imphook.py", line 417, in post_graph
    self._load_hook_module()
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\depend\imphook.py", line 384, in _load_hook_module
    self.hook_module_name, self.hook_filename)
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\compat.py", line 797, in importlib_load_source
    return mod_loader.load_module()
  File "<frozen importlib._bootstrap_external>", line 407, in _check_name_wrapper
  File "<frozen importlib._bootstrap_external>", line 907, in load_module
  File "<frozen importlib._bootstrap_external>", line 732, in load_module
  File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\hooks\hook-google.cloud.py", line 13, in <module>
    datas = copy_metadata('google-cloud-core')
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\PyInstaller\utils\hooks\__init__.py", line 859, in copy_metadata
    dist = pkg_resources.get_distribution(package_name)
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\pkg_resources\__init__.py", line 482, in get_distribution
    dist = get_provider(dist)
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\pkg_resources\__init__.py", line 358, in get_provider
    return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\pkg_resources\__init__.py", line 901, in require
    needed = self.resolve(parse_requirements(requirements))
  File "c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site-packages\pkg_resources\__init__.py", line 787, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'google-cloud-core' distribution was not found and is required by the application

Project output will not be moved to output folder
Complete.
运行自动复制到exe v2.7.6
建筑目录:C:\Users\mukanrom\AppData\Local\Temp\tmp\u 9eu06ny
提供的命令:pyinstaller--noconfirm--onedir--console“C:/label reader/label_reader.py”
递归限制设置为5000
执行:pyinstaller--noconfirm--onedir--console C:/label reader/label\u reader.py--distpath C:\Users\mukanrom\AppData\Local\Temp\u 9eu06ny\application--workpath C:\Users\mukanrom\AppData\Local\Temp\u 9eu06ny\build--specpath C:\Users\mukanrom\AppData\Local\Temp\u 9eu06ny
93640信息:PyInstaller:3.6
93644信息:Python:3.7.7
93647信息:平台:Windows-10-10.0.17763-SP0
93651信息:写入C:\Users\mukanrom\AppData\Local\Temp\tmp\u 9eu06ny\label\u reader.spec
93657信息:UPX不可用。
93661信息:使用路径扩展PYTHONPATH
['C:\\label reader','C:\\Users\\mukanrom\\AppData\\Local\\Temp\\tmp\u 9eu06ny']
93665信息:检查分析
93668信息:生成分析,因为Analysis-00.toc不存在
93672信息:正在初始化模块依赖关系图。。。
93683信息:缓存模块图形挂钩。。。
93695信息:正在分析base_library.zip。。。
95908信息:处理预查找模块路径挂钩区
95913信息:distutils:重定目标到非venv目录'c:\\documents\\wpy64-3770\\python-3.7.7.amd64\\lib'
97515信息:缓存模块依赖关系图。。。
97607信息:运行分析-00.toc
97628信息:将Microsoft.Windows.Common-Controls添加到最终可执行文件的相关程序集
c:\documents\wpy64-3770\python-3.7.7.amd64\python.exe所需
97700信息:正在分析C:\label reader\label\u reader.py
108983信息:处理预安全导入模块hook setuptools.extern.six.moves
109942信息:正在处理预查找模块路径挂钩站点
109948信息:站点:重新定位到伪目录'c:\\documents\\wpy64-3770\\python-3.7.7.amd64\\lib\\site packages\\PyInstaller\\fake modules'
124233信息:正在处理预安全导入模块hook six.moves
134498信息:正在处理预安全导入模块挂钩urllib3.packages.six.moves
136163信息:正在处理预查找模块路径钩子PyQt5.uic.port_v3
136278信息:正在处理预查找模块路径钩子PyQt5.uic.port_v2
136587信息:处理模块挂钩。。。
136591信息:加载模块挂钩“hook certifi.py”。。。
136596信息:加载模块钩子“hook cryptography.py”。。。
136921信息:加载模块挂钩“hook distutils.py”。。。
136926信息:加载模块钩子“hook django.core.cache.py”。。。
137107信息:加载模块钩子“hook django.core.mail.py”。。。
137158信息:加载模块hook“hook django.core.management.py”。。。
137178信息:未找到要排除的导入:“IPython”
137184信息:不包括导入“tkinter”
137192信息:未找到要排除的导入:“matplotlib”
137195信息:加载模块hook“hook django.db.backends.py”。。。
138715警告:找不到隐藏的导入“django.db.backends.\uuuu pycache\uuuuu.base”!
138718信息:加载模块钩子“hook django.py”。。。
140567信息:确定分发到包的映射。。。
242008信息:django需要的软件包:
['asgiref','sqlparse','pytz']
259593信息:加载模块挂钩“hook docutils.py”。。。
262424信息:加载模块hook“hook encodings.py”。。。
262547信息:加载模块挂钩“hook gevent.py”。。。
262852警告:无法从包gevent中找到需求zope.event的包。
262857警告:无法从包gevent中找到需求zope.interface的包。
262860警告:无法从包gevent中找到需求greenlet的包。
262869信息:gevent所需的软件包:
['cffi','setuptools']
264109信息:加载模块钩子“hook google.api.py”。。。
264116信息:加载模块钩子“hook google.api_core.py”。。。
264121信息:加载模块挂钩“hook google.cloud.py”。。。
打包时出错
回溯(最近一次呼叫最后一次):
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\auto\u py\u to\u exe\packaging.py”,第131行,在包中
运行安装程序()
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\\uuuuu main\uuuuuuuu.py”,第114行,正在运行
运行构建(pyi\u配置,规范文件,**vars(args))
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\uuuuu main\uuuuuuu.py”,第65行,在run\u build中
PyInstaller.building.build\u main.main(pyi\u配置,spec\u文件,**kwargs)
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\building\build\u main.py”,第734行,在main中
构建(specfile,kw.get('distpath'),kw.get('workpath'),kw.get('clean_build'))
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\building\build\u main.py”,第681行,内部版本
exec(代码、规范和命名空间)
文件“C:\Users\mukanrom\AppData\Local\Temp\tmp\u 9eu06ny\label\u reader.spec”,第17行,在
无存档=假)
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\building\build\u main.py”,第244行,在\uuu init中__
self.\uuuu postinit\uuuuu()
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\building\datastruct.py”,第160行,在__
self.assembly()
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\building\build\u main.py”,第422行,汇编
self.graph.process\u post\u graph\u hooks()
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstaller\depend\analysis.py”,第311行,进程中\u post\u图形\u钩子
模块\u hook.post\u图()
文件“c:\documents\wpy64-3770\python-3.7.7.amd64\lib\site packages\PyInstalle