• TypeError: 'module' object is not callable


    1、错误描述

    Traceback (most recent call last):
      File "E:PyCharmhelperspydevpydev_run_in_console.py", line 52, in run_file
        pydev_imports.execfile(file, globals, locals)  # execute the script
      File "E:PyCharmhelperspydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
        exec(compile(contents+"
    ", file, 'exec'), glob, loc)
      File "E:/PycharmProjects/cdk/venv/plotly/a.py", line 9, in <module>
        y = [12,45,67,32,46,89,54,2,89]
    TypeError: 'module' object is not callable

    2、错误原因

    import plotly;
    import plotly.plotly as py;
    import plotly.graph_objs as go;
    
    plotly.tools.set_credentials_file(username='XXX',api_key='jkjdkja8798');
    
    A = go.scatter(
        x = [1,2,3,4,5,6,7,8,9],
        y = [12,45,67,32,46,89,54,2,89]
    )
    
    data = [A];
    
    py.iplot(data,filename='直线');

         出现错误的地方是定义变量A,声明y坐标地方,错误原因是scatter,应该为Scatter

    3、解决办法

          将scatter修改为Scatter

    import plotly;
    import plotly.plotly as py;
    import plotly.graph_objs as go;
    
    plotly.tools.set_credentials_file(username='youhaidong',api_key='fl1sPa0GMIkz1R3Z1BHy');
    
    A = go.Scatter(
        x = [1,2,3,4,5,6,7,8,9],
        y = [12,45,67,32,46,89,54,23,89]
    )
    
    data = [A];
    
    py.plot(data,filename='直线');
  • 相关阅读:
    收集一些网络检测和分析工具
    编程经验分享(转自银总的建议)
    代码着色和windows live writer真好
    pku1063 Flip and Shift严格证明
    So Many Skirt
    一些网址
    c++编写的算24程序
    一道简单的回溯搜索题
    windows程序设计第二章Unicode简介
    字符,字节和编码
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13313759.html
Copyright © 2020-2023  润新知