1

I'm having a problem using Anaconda 3, plotly and cx_freeze to generate an executable. Maybe you guys can enlighten my mind. I can generate the .exe but when I run it I get this:

Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\lib\site-            
packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
    module.run()
  File "C:\ProgramData\Anaconda3\lib\site-
packages\cx_Freeze\initscripts\Console.py", line 26, in run
    exec(code, m.__dict__)
  File "main.py", line 15, in <module>
  File "C:\Users\a\Documents\b\c\plot_3d.py", line 
1, in <module>
    import plotly as py
  File "C:\ProgramData\Anaconda3\lib\site-packages\plotly\__init__.py", line 
31, in <module>
    from plotly import (plotly, dashboard_objs, graph_objs, grid_objs, 
tools,
  File "C:\ProgramData\Anaconda3\lib\site-
packages\plotly\graph_objs\__init__.py", line 14, in <module>
    from plotly.graph_objs.graph_objs import *  # this is protected with 
__all__
  File "C:\ProgramData\Anaconda3\lib\site-
packages\plotly\graph_objs\graph_objs.py", line 34, in <module>
    from plotly import exceptions, graph_reference
  File "C:\ProgramData\Anaconda3\lib\site-
packages\plotly\graph_reference.py", line 9, in <module>
    from pkg_resources import resource_string
ModuleNotFoundError: No module named 'pkg_resources'

Looks like I'm having problem with plotly. After searching for a while I still couldn't fin a solution. This is my setup.py:

import sys

kwargs = {"name": "x",
          "version": "1.2",
          "author": "x",
          "author_email": "x",
          "description": "x",
          "zip_safe": False
          }

try:
    if sys.argv[1] == "build":
        import os
        from setuptools import find_packages
        from cx_Freeze import setup, Executable

        os.environ["TCL_LIBRARY"] = r"C:\\ProgramData\\Anaconda3\\tcl\\tcl8.6"
        os.environ["TK_LIBRARY"] = r"C:\\ProgramData\\Anaconda3\\tcl\\tk8.6"

        kwargs["options"] = {
            "build_exe": {
                "packages": find_packages() + ["os", "numpy", "plotly"],
                "includes": ["numpy", "plotly"],
        }
    }
    kwargs["executables"] = [Executable(r"main.py", base="console")]

    setup(**kwargs)
except Exception as e:
    print(e)

I have tried this solution without success, any suggestion? Thanks.

  • `ModuleNotFoundError: No module named 'pkg_resources`. Can you confirm this file exists in your env path? – Noqomo Aug 11 '17 at 18:46
  • @Noqomo excuse me, which file are you referring to? If you mean graph_reference, yes its in C:\ProgramData\Anaconda3\Lib\site-packages\plotly – Felipe Barbosa Aug 11 '17 at 18:58
  • Hi, I am referring to your `pkg_resources` which appears to be missing. I would try `pip install --upgrade setuptools` and `pip install --upgrade distribute` to make sure it isn't corruption. – Noqomo Aug 11 '17 at 19:32
  • For some reason I can't perform pip install --upgrade distribute, I'm checking why I get: AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader' – Felipe Barbosa Aug 14 '17 at 19:53
  • @Noqomo Hi, after trying many times the solution was to put every module inside ` "includes": ["numpy", "plotly", "pkg_resources", "appdirs", "packaging.specifiers", "packaging.requirements"]` – Felipe Barbosa Aug 15 '17 at 16:19

1 Answers1

0

The solution was to include every package in:

"includes": ["numpy", "plotly", "pkg_resources", "appdirs", "packaging.specifiers", "packaging.requirements"]