Forums

facet_col_wrap argument not being recognised in Python Anywhere

Hello,

I have created a simple script that creates a plotly.express.line using one the argument facet_col_wrap to ensure I have a nice visual result.

When running the script I get this error:

TypeError: line() got an unexpected keyword argument 'facet_col_wrap'

When I run the file without that argument, there is no error and the graph is saved.

I checked that the pre-installed version of plotly in Pythonanywere is 4.2.1. I don't understand what could be wrong. I am importing plotly.express (which I think its contained inside Plotly)

Has anybody had any issues with this? How do I ensure that I am using the correct version?

Can you show full traceback error message?

The full Traceback error message is:

Traceback (most recent call last):
  File "/home/mhukamazon/mysite/Rolling Graph MHE.py", line 77, in <module>
    figx = px.line(rolling_df, x="date", y="7_day_avg_cases", facet_col="Country/Region", facet_col_wrap=5,
TypeError: line() got an unexpected keyword argument 'facet_col_wrap'

The Line 77 it refers to is:

figx = px.line(rolling_df, x="date", y="7_day_avg_cases", facet_col="Country/Region", facet_col_wrap=5, height=600, width=1200)

Thanks!

It looks like facet_col_wrap was introduced in Plotly 4.3 (see here), so you'll need to upgrade the version that you are using.

I'm guessing from your post that you are not using a virtualenv, so you'll need to use the --user flag with the appropriate pip command to upgrade it. For example, if you're using Python 3.7 the command (in Bash) would be:

pip3.7 install --user --upgrade plotly

Hi Giles,

Indeed this one upgraded plotly and then I was able to run the script without problems!

pip3.8 install --user --upgrade plotly

Thank you!

Good to hear that you made it work!