简体   繁体   English

获取AttributeError:运行cx_Freeze可执行文件时,模块'tensorflow_estimator.python.estimator.api.estimator'没有属性'__file__'

[英]Getting AttributeError: module 'tensorflow_estimator.python.estimator.api.estimator' has no attribute '__file__' when running a cx_Freeze executable

I'm trying to compile this python script: 我正在尝试编译此python脚本:

from keras import optimizers
from keras.models import Sequential
from keras.models import model_from_json


from keras.layers import Dense, Flatten

import time
import tkinter
import cv2
import PIL.Image, PIL.ImageTk
from matplotlib import pyplot as plt
import numpy as np
import pickle
from pathlib import Path

import threading

input("waiting for input")
exit()

Using this script: 使用此脚本:

cxfreeze test.py --target-dir dist --include-modules=numpy.core._methods,numpy.lib.format,tensorflow.python.tf2,tensorflow.python.tools.component_api_helper

But I get the error in the title when I run the executable. 但是运行可执行文件时,标题出现错误。 I even tried to reinstall every tensorflow package with no result. 我什至尝试重新安装每个tensorflow软件包,但没有结果。 I'm working on a virtual environment. 我正在虚拟环境中工作。

Full log: 完整日志:

davidaffo@davidaffo-TM1701:~/PycharmProjects/EyeTracker$ source ./venv/bin/activate
(venv) davidaffo@davidaffo-TM1701:~/PycharmProjects/EyeTracker$ ./dist/test
Using TensorFlow backend.
Traceback (most recent call last):
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/cx_Freeze/initscripts/__startup__.py", line 14, in run
    module.run()
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/cx_Freeze/initscripts/Console.py", line 26, in run
    exec(code, m.__dict__)
  File "test.py", line 1, in <module>
    from keras import optimizers
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/tensorflow/__init__.py", line 29, in <module>
    from tensorflow._api.v1 import compat
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/tensorflow/_api/v1/compat/__init__.py", line 21, in <module>
    from tensorflow._api.v1.compat import v1
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/tensorflow/_api/v1/compat/v1/__init__.py", line 626, in <module>
    child_package_str=('tensorflow_estimator.python.estimator.api.estimator'))
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/tensorflow/python/tools/component_api_helper.py", line 85, in package_hook
    set_child_as_subpackage()
  File "/home/davidaffo/PycharmProjects/EyeTracker/venv/lib/python3.6/site-packages/tensorflow/python/tools/component_api_helper.py", line 69, in set_child_as_subpackage
    os.path.join(os.path.dirname(child_pkg.__file__), ".."))]
AttributeError: module 'tensorflow_estimator.python.estimator.api.estimator' has no attribute '__file__'

Try to add to tensorflow and maybe tensorflow_estimator and keras to the --include-modules comma-separated list. 尝试添加到tensorflow以及tensorflow_estimatorkerastensorflow_estimator --include-modules逗号分隔列表中。

Or try to use the distutils setup script and to add tensorflow and maybe tensorflow_estimator and keras to the packages list of the build_exe option. 或者尝试使用distutils安装脚本并将tensorflow以及tensorflow_estimatorkerasbuild_exe选项的packages列表中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当使用tf-tutorials运行时发生了:AttributeError:模块&#39;tensorflow.python.estimator.api.estimator&#39;没有属性&#39;SessionRunHook&#39; - when run with tf-tutorials it happened:AttributeError: module 'tensorflow.python.estimator.api.estimator' has no attribute 'SessionRunHook' 模块“tensorflow_estimator.python.estimator.api._v2.estimator”没有属性“输入” - module 'tensorflow_estimator.python.estimator.api._v2.estimator' has no attribute 'inputs' AttributeError:模块“ tensorflow.contrib”没有属性“ estimator” - AttributeError: module 'tensorflow.contrib' has no attribute 'estimator' AttributeError:使用CX_FREEZE构建Python 3.6可执行文件时,模块&#39;dis&#39;没有属性&#39;_unpack_opargs&#39; - AttributeError: module 'dis' has no attribute '_unpack_opargs' While Building Python 3.6 executable using CX_FREEZE 估算器API:AttributeError:&#39;NoneType&#39;对象没有属性&#39;dtype&#39; - Estimator API: AttributeError: 'NoneType' object has no attribute 'dtype' 使用 cx_Freeze 将 python 文件转换为可执行文件,然后得到错误 AttributeError: &#39;list&#39; object has no attribute &#39;main_script&#39; - Convert a python file into an executable with cx_Freeze then get error AttributeError: 'list' object has no attribute 'main_script' 如何修复“模块‘tensorflow’没有属性‘estimator’”错误 - How to fix "module 'tensorflow' has no attribute 'estimator' " error 使用`tensorflow.python.keras.estimator.model_to_estimator`将Keras模型转换为Estimator API时如何通知类权重? - How to inform class weights when using `tensorflow.python.keras.estimator.model_to_estimator` to convert Keras Models to Estimator API? Python,AttributeError:cx_Freeze 构建后,模块“google.cloud.bigquery”没有属性“Client” - Python, AttributeError: module 'google.cloud.bigquery' has no attribute 'Client' after cx_Freeze build 将imaplib与cx_Freeze一起使用时,获取“模块&#39;imaplib&#39;没有属性&#39;IMAP4_SSL&#39;” - Getting “module 'imaplib' has no attribute 'IMAP4_SSL'” when using imaplib with cx_Freeze
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM