tableau 连接python - Go语言中文社区

tableau 连接python


最简单的方式就是装一个现成的环境,anaconda,在里面安装两个包

在C盘中搜索startup.bat,放在桌面比较方便,运行弹出此界面即可。

 

Done!!!

参考资料1:https://onlinehelp.tableau.com/current/api/extract_api/en-us/Extract/extract_api_using_python.htm

Using the Extract API 2.0 with Python

This topic describes how to install the Extract API for Python and how to reference the Extract API library in Python code.

Note: To perform these steps, you must run as a user who has administrator access.

  1. Extract the Python package that you downloaded into a directory on your computer. For details, see Installing the Extract API 2.0.

  2. At the command line, go to the directory where you extracted the package.

  3. Open a command window as a root or administrator user.

  4. On a Windows computer, run the following commands:

    python setup.py build
    python setup.py install

    On a Linux or Apple computer, use the following commands:

    sudo python setup.py install

    After entering the sudo command, you might be asked to enter your password.

  5. In your Python code, import the API that you want to work with using syntax like this:

    from tableausdk import *
    from tableausdk.HyperExtract import *

参考资料2:http://blog.sina.com.cn/s/blog_af8b11b50102xap5.html

一、Python编译器安装

Python编译器以pycharm为例,下载方式和安装的方法不再介绍。 

二、Tabpy-Server环境搭建

在Tableau公司的Github主页下,有一个名为Tabpy的项目,提供了Tableau和Python集成的套件:Tabpy framework。

GitHub下载地址:https://github.com/tableau/TabPy

Tabpy Server安装方法有两种:

(1)官方提供了一个整体打包的方案,可以从GitHub页面下载整个项目到本地,点击setup.bat或setup.sh文件就可以自动下载Anaconda环境,创建一个名为Tableau-Python-Server的环境,并且在这个环境中安装好Tabpy及相关的各种库。

(2)也可以手动安装,手动安装的步骤如下(以Windows平台为例):

a)本机下载安装Anaconda,把Anaconda的Python环境加入到环境变量;

b)运行以下命令在Anaconda上建立一个名为Tableau-Python-Server的环境,在本机搜索程序Anaconda Prompt点击进入,在此命令框输入命令(可指定Python的版本):

conda create --name Tableau-Python-Server python=2.7 anaconda

c) 运行以下命令切换到新创建的环境:

activate Tableau-Python-Server

然后运行命令安装Tabpy

pip install tabpy-server

如果命令运行一切正常,你可以在anaconda安装目录中进行查看是否存在启动选项,在路径...anacondaenvsTableau-Python-ServerLibsite-packages下看到一个名为tabpy_server的文件夹,里面包含了一个用于启动Tabpy server的startup.bat文件,可以把它创建一个快捷方式到你的桌面,以后你会需要经常点击它启动Tabpy Server。

截至目前,就可以启动Tabpy Server,打开tableau然后在外部服务器中配置本地IP和端口9004,然后在计算字段中写python代码了。

三、PyCharm修改默认运行环境

打开PyCharm,点击File—Settings—Project —Project Interpreter可以进入如图的界面,可以选择Existing environment选择TabPy中的Python环境,根据自己的安装位置,地址大致是:...Anaconda3envsTableau-Python-Serverpython.exe。选择后确定即可。

到此为止,在PyCharm中运行Python代码就发布到了Tabpy-server中,Tableau中使用计算字段就可以调用。

版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/sinat_34802933/article/details/81391755
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2020-04-18 21:21:37
  • 阅读 ( 998 )
  • 分类:

0 条评论

请先 登录 后评论

官方社群

GO教程

推荐文章

猜你喜欢