ModuleNotFoundError:在Python 3.6.7上没有名为“ google”的模块 [英] ModuleNotFoundError: No module named 'google' on python 3.6.7
问题描述
我正在编写一个脚本,该脚本接收一些参数,并使用这些参数来操纵Firebase实时数据库。
I'm making a script that receives some args and use these args to manipulate a Firebase Realtime Database.
在cmd上运行脚本(我在Windows 10计算机上)时,键入 mpython myScript.py arg1 arg2 ...
可以正常工作。但是,当我使用cx_Freeze构建我的.exe时,它说缺少模块
When I run the script on cmd (I'm on a Windows 10 computer) by typing mpython myScript.py arg1 arg2 ...
it works fine. But when I use cx_Freeze to build my .exe it says that there are modules missing
Missing modules:
? Cookie imported from requests.compat
? OpenSSL.SSL imported from urllib3.contrib.pyopenssl
? OpenSSL.crypto imported from urllib3.contrib.pyopenssl
? StringIO imported from requests.compat, six, urllib3.packages.six
....
? urllib3.packages.six.moves.urllib.parse imported from
urllib3.poolmanager, urllib3.request
? urlparse imported from requests.compat
? vms_lib imported from platform
This is not necessarily a problem - the modules may not be needed on this
platform.
它还显示
Traceback (most recent call last):
File "C:\Users\engenharia1\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\Users\engenharia1\AppData\Local\Programs\Python\Python36\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "Api2.py", line 8, in <module>
File "C:\Users\engenharia1\AppData\Local\Programs\Python\Python36\lib\site-packages\firebase_admin\__init__.py", line 23, in <module>
from firebase_admin import credentials
File "C:\Users\engenharia1\AppData\Local\Programs\Python\Python36\lib\site-packages\firebase_admin\credentials.py", line 20, in <module>
import google.auth
ModuleNotFoundError: No module named 'google'
我的 setup.py
import sys
from cx_Freeze import setup, Executable
setup (
name = "pyFirebase",
version = "1.1",
executables = [Executable("pyFirebase.py")]
)
我在 pyFirebase.py
(由于我的工作而没有显示整个程序,对不起)
My imports on pyFirebase.py
(not showing the whole program because it's from my job, I can't, sorry)
import sys
import os
import datetime
import firebase_admin
from firebase_admin import credentials
from firebase_admin import db
from random import randint
我对args的处理方式
And my way of handling with the args
if(len(sys.argv) == 5):
var1 = args[1]
我仅使用args并构建了.exe进行了测试,因此它可以正常工作问题与模块或环境有关。
I did a test using just the args and building the .exe and it worked, so probably the issue is with the modules or with my environment.
有什么想法吗?
推荐答案
编辑:尝试如下修改您的 setup.py
:
try to modify your setup.py
as follows:
import sys
from cx_Freeze import setup, Executable
include_files = []
packages = ['google']
build_exe_options = {'include_files': include_files,
'packages': packages}
setup (
name = "pyFirebase",
version = "1.1",
options = {'build_exe': build_exe_options},
executables = [Executable("pyFirebase.py")]
)
google
使用请求
,您会找到有关如何使用的其他信息请求库中的
>请求库:缺少SSL握手cx_Freeze 之后的证书文件。 cx_Freeze
中的请求
google
uses requests
, you'll find additional information on how to use requests
with cx_Freeze
in Requests library: missing SSL handshake certificates file after cx_Freeze.
您可能还需要添加任何必要的fi le(许可证文件,证书……)到 include_files
列表。
You might further need to add any necessary file (license file, certificate, ...?) to the include_files
list.
由 cx_Freeze
报告的code>缺少模块列表值得关注,这不一定是问题。
As far as the Missing modules
list reported by cx_Freeze
is concerned, this is not necessarily a problem.
这篇关于ModuleNotFoundError:在Python 3.6.7上没有名为“ google”的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!