Navigation

    Backtrader Community

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    For code/output blocks: Use ``` (aka backtick or grave accent) in a single line before and after the block. See: http://commonmark.org/help/

    cannot import name 'warnings' from 'matplotlib.dates'

    General Code/Help
    5
    5
    7954
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Igor-san
      Igor-san last edited by

      I did not find the Issues section in GitHub.

      Python 3.8.3
      Matplotlib 3.3.0

      file "github.com\backtrader-master\backtrader\plot\locator.py", line 35, in <module>
          from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN,
      ImportError: cannot import name 'warnings' from 'matplotlib.dates' (C:\Python38\lib\site-packages\matplotlib\dates.py)
      

      But I changed the import line and it work for me

      from matplotlib import warnings
      
      1 Reply Last reply Reply Quote 0
      • vladisld
        vladisld last edited by

        I think the PR was submitted fixing this exact issue:

        https://github.com/mementum/backtrader/pull/418

        1 Reply Last reply Reply Quote 2
        • P
          phat last edited by

          @Igor-san said in cannot import name 'warnings' from 'matplotlib.dates':

          section

          I reinstall the matplotlib with version 3.2.0 and everything is fine.

          1 Reply Last reply Reply Quote 1
          • Yuan Xin
            Yuan Xin last edited by

            Matplotlib 3.3.x is not compatible with backtrader. Matplotlib 3.2.0 is fine.
            Matplotlib 3.3.x cause strange problem, plot function will exhaust memory!
            my dev env:
            1, Mac OS
            2, python 3.7.9
            3, backtrader 1.9.76.123
            4, Matplotlib 3.2.0
            5, pycharm
            6, datafeed: pandas dataframe

            1 Reply Last reply Reply Quote 0
            • W
              wildajet last edited by

              MacOS big Sur
              python 3.9.2
              matplotlib 3.3.4
              backtrader 1.9.76.123

              Change /usr/local/lib/python3.9/site-packages/backtrader/plot/locator.py

              from:
              from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN,
              MONTHS_PER_YEAR, DAYS_PER_WEEK,
              SEC_PER_HOUR, SEC_PER_DAY,
              num2date, rrulewrapper, YearLocator,
              MicrosecondLocator, warnings)

              to:
              from matplotlib import warnings
              from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN,
              MONTHS_PER_YEAR, DAYS_PER_WEEK,
              SEC_PER_HOUR, SEC_PER_DAY,
              num2date, rrulewrapper, YearLocator,
              MicrosecondLocator)

              1 Reply Last reply Reply Quote 3
              • 1 / 1
              • First post
                Last post
              Copyright © 2016, 2017, 2018, 2019, 2020, 2021 NodeBB Forums | Contributors