<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Python module error - matplotlib.use('Agg') in Developer</title>
    <link>https://community.fabric.microsoft.com/t5/Developer/Python-module-error-matplotlib-use-Agg/m-p/1621308#M27482</link>
    <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some simple Python code to read an Excel Worksheet.&lt;/P&gt;&lt;P&gt;The code works in PyCharm IDE, but I get an error in Power BI.&lt;/P&gt;&lt;P&gt;I have spent two hours using Conda to remove, and pip to install the Python modules, but keep getting errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would really appreciate any pointers to resolve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python
# coding: utf-8
import os, sys
import pandas as pd
import xlrd
import openpyxl, xlsxwriter

Jan2021 = r"mypath\2021_01.xlsx"

RouteJan = pd.read_excel(Jan2021, sheet_name='Route')
print(RouteJan)

Error msg:
Details: "ADO.NET: Python script error.
Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 3, in &amp;lt;module&amp;gt;
    matplotlib.use('Agg')
AttributeError: module 'matplotlib' has no attribute 'use'&lt;/LI-CODE&gt;</description>
    <pubDate>Mon, 25 Jan 2021 14:55:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2021-01-25T14:55:00Z</dc:date>
    <item>
      <title>Python module error - matplotlib.use('Agg')</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Python-module-error-matplotlib-use-Agg/m-p/1621308#M27482</link>
      <description>&lt;P&gt;Greetings,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some simple Python code to read an Excel Worksheet.&lt;/P&gt;&lt;P&gt;The code works in PyCharm IDE, but I get an error in Power BI.&lt;/P&gt;&lt;P&gt;I have spent two hours using Conda to remove, and pip to install the Python modules, but keep getting errors.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would really appreciate any pointers to resolve this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#!/usr/bin/env python
# coding: utf-8
import os, sys
import pandas as pd
import xlrd
import openpyxl, xlsxwriter

Jan2021 = r"mypath\2021_01.xlsx"

RouteJan = pd.read_excel(Jan2021, sheet_name='Route')
print(RouteJan)

Error msg:
Details: "ADO.NET: Python script error.
Traceback (most recent call last):
  File "PythonScriptWrapper.PY", line 3, in &amp;lt;module&amp;gt;
    matplotlib.use('Agg')
AttributeError: module 'matplotlib' has no attribute 'use'&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 25 Jan 2021 14:55:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Python-module-error-matplotlib-use-Agg/m-p/1621308#M27482</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2021-01-25T14:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python module error - matplotlib.use('Agg')</title>
      <link>https://community.fabric.microsoft.com/t5/Developer/Python-module-error-matplotlib-use-Agg/m-p/1625403#M27518</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I did not reproduce your problem.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="v-lionel-msft_2-1611732376806.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/441170i089B13A255B76CC3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="v-lionel-msft_2-1611732376806.png" alt="v-lionel-msft_2-1611732376806.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="v-lionel-msft_0-1611732277401.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/441168i3CFF3098A5B6FD0C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="v-lionel-msft_0-1611732277401.png" alt="v-lionel-msft_0-1611732277401.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can try this.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;#!/usr/bin/env python
# coding: utf-8
import os, sys
import pandas as pd
import xlrd
import openpyxl, xlsxwriter
import matplotlib
matplotlib.use('agg')
import matplotlib.pyplot as plt # matplotlib.use('agg') must be run before this sentence is executed

Jan2021 = r'C:\Users\lionelch\Desktop\Sampledata\2021_01.xlsx'

RouteJan = pd.read_excel( Jan2021, sheet_name='Route')
print(RouteJan)
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best regards,&lt;BR /&gt;Lionel Chen&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jan 2021 07:37:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Developer/Python-module-error-matplotlib-use-Agg/m-p/1625403#M27518</guid>
      <dc:creator>v-lionel-msft</dc:creator>
      <dc:date>2021-01-27T07:37:49Z</dc:date>
    </item>
  </channel>
</rss>

