Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ImportError from matplotlib.dates #418

Merged
merged 1 commit into from Feb 11, 2021
Merged

Fix ImportError from matplotlib.dates #418

merged 1 commit into from Feb 11, 2021

Conversation

Larry-u
Copy link
Contributor

@Larry-u Larry-u commented Jul 19, 2020

matplotlib.dates does not have a module called warnings

Reference: https://matplotlib.org/3.1.1/api/dates_api.html

matplotlib.dates does not have a module called `warnings`

Reference: https://matplotlib.org/3.1.1/api/dates_api.html
@NSSmithPortfolio
Copy link

Confirmed working, I made the change manually until committed.

@eugeneyng
Copy link

eugeneyng commented Aug 19, 2020

I had this issue as well; while we are waiting for the pull request I just wanted to say that my fix was reverting to a previous version of matplotlib

pip uninstall matplotlib
pip install matplotlib==3.1.1

@hardikpatel043
Copy link

version 3.2.2 worked for me
pip uninstall matplotlib
pip install matplotlib==3.2.2

@shashiHUB
Copy link

version 3.2.2 worked for me
pip uninstall matplotlib
pip install matplotlib==3.2.2

I have no luck. Can please tell me what is your python version ? Thx

@hardikpatel043
Copy link

hardikpatel043 commented Sep 8, 2020

version 3.2.2 worked for me
pip uninstall matplotlib
pip install matplotlib==3.2.2

I have no luck. Can please tell me what is your python version ? Thx

My python version is 3.8.5

@camsteffen camsteffen mentioned this pull request Sep 19, 2020
@damonYuan
Copy link

can we also update

extras_require={
        'plotting':  ['matplotlib'],
    },

to

extras_require={
        'plotting':  ['matplotlib==3.2.2'],
    },

@NSSmithPortfolio
Copy link

Python 3.6

@zetatez
Copy link

zetatez commented Oct 9, 2020 via email

@vijay-r
Copy link

vijay-r commented Jan 12, 2021

Please merge this PR
still facing same issue

    from matplotlib.dates import (HOURS_PER_DAY, MIN_PER_HOUR, SEC_PER_MIN,
ImportError: cannot import name 'warnings' from 'matplotlib.dates' (/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/matplotlib/dates.py)

@fugaz
Copy link

fugaz commented Jan 21, 2021

+1 to have this PR merged
FWIW, it works on macOS big sur, and it also allows to use matplotlib 4 (version 3.2.2 is not compatible with big sur)

@dmiladinovich
Copy link

I'll add to this. Your noobies (like myself) are encountering this issue while learning. See the Quick Start guide at the end is a call to cerebro.plot().

I will say, as a noobie, the act of googling this issue, finding the community fix and then joining in on the conversation, was a nice quick start to joining the community as well.

Cheers to staying positive.

@ScientiaCapital
Copy link

ScientiaCapital commented Feb 6, 2021 via email

@vladisld vladisld merged commit 0fa63ef into mementum:master Feb 11, 2021
@dvdtth
Copy link

dvdtth commented Mar 2, 2021

when can we expect a new release with this fix in it?

@dorak88783
Copy link

A new version would be great - I now can't even run the simplest example without manual workarounds.

@ptim
Copy link

ptim commented Mar 30, 2021

You can install the merged patch if you specify the commit hash:

pip install git+https://github.com/mementum/backtrader.git@0fa63ef4a35dc53cc7320813f8b15480c8f85517#egg=backtrader

More details: https://stackoverflow.com/a/66871735/2586761

(working for me on python3.9)

cc @dorak88783 @dvdtth

@GF-Huang
Copy link

GF-Huang commented Jul 23, 2021

Why still not release a new version to pip?

@GF-Huang
Copy link

You can install the merged patch if you specify the commit hash:

pip install git+https://github.com/mementum/backtrader.git@0fa63ef4a35dc53cc7320813f8b15480c8f85517#egg=backtrader

More details: stackoverflow.com/a/66871735/2586761

(working for me on python3.9)

cc @dorak88783 @dvdtth

Seems not work, still old version.

image

@GF-Huang
Copy link

GF-Huang commented Jul 23, 2021

It works after pip uninstall backtrader then reinstall again.

But:

image

@reisenmachtfreude
Copy link

Bug is still there. I've uninstalled and installed the module again:
pip3 install backtrader

Collecting backtrader
  Downloading backtrader-1.9.76.123-py2.py3-none-any.whl (410 kB)
Installing collected packages: backtrader
Successfully installed backtrader-1.9.76.123

Error:

  File "/home/something/.local/lib/python3.9/site-packages/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' (/home/ping/.local/lib/python3.9/site-packages/matplotlib/dates.py)

@GF-Huang
Copy link

Bug is still there. I've uninstalled and installed the module again:
pip3 install backtrader

Collecting backtrader
  Downloading backtrader-1.9.76.123-py2.py3-none-any.whl (410 kB)
Installing collected packages: backtrader
Successfully installed backtrader-1.9.76.123

Error:

  File "/home/something/.local/lib/python3.9/site-packages/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' (/home/ping/.local/lib/python3.9/site-packages/matplotlib/dates.py)

pip uninstall backtrader

then

pip install git+https://github.com/mementum/backtrader.git@0fa63ef4a35dc53cc7320813f8b15480c8f85517#egg=backtrader

@reisenmachtfreude
Copy link

@GF-Huang Thank you very much. Like that it works.

@cfpavon
Copy link

cfpavon commented Sep 23, 2021

Getting this some bug....while using backtrader from conda installation...

@mrx23dot
Copy link

When will be this released? pypi version (1.9.76.123) is still has this bug.

Grenite pushed a commit to Grenite/backtrader that referenced this pull request Dec 2, 2021
Fix ImportError from matplotlib.dates
@henke443
Copy link

henke443 commented Jun 3, 2022

Why is this still not fixed?

@Jay357
Copy link

Jay357 commented Jun 24, 2022

I've recently started using backtrader.

  • Python 3.10.5
  • pip 22.1.2
  • matplotlib 3.5.2
  • backtrader 1.9.76.123

Whenever I try to execute: cerebro.plot() This error occurs:
Exception has occurred: ImportError
cannot import name 'warnings' from 'matplotlib.dates' (C:\Users\ [user]\AppData\Local\Programs\Python\Python310\lib\site-packages\matplotlib\dates.py)
File "C:\Users\ [user]\ [folder]\ [folder]\ [folder]\ [folder]\run.py", line 23, in
cerebro.plot()

Is there any workaround at this stage? When is the bug fix coming?

@LeMoussel
Copy link

The patch is the latest commit to master, but there hasn't been a release.
In the meantime do what is indicated by GF-Huang

You could alternatively specify the required commit in requirements.txt like so:
-e git+https://github.com/mementum/backtrader.git@0fa63ef4a35dc53cc7320813f8b15480c8f85517#egg=backtrader
then pip install -r requirements.txt

@rahultandale3
Copy link

Why is this still not fixed?

he man i am also facing the same problem , can you connect me https://t.me/rahul08T

@ariv803
Copy link

ariv803 commented Sep 24, 2022

I'll add to this. Your noobies (like myself) are encountering this issue while learning. See the Quick Start guide at the end is a call to cerebro.plot().

I will say, as a noobie, the act of googling this issue, finding the community fix and then joining in on the conversation, was a nice quick start to joining the community as well.

Cheers to staying positive.

Are you implying a solution or workaround to this issue is in the quick start link?

@AkiraCharles
Copy link

AkiraCharles commented Mar 22, 2023

Is there any update on this issue. I'm using:
python- 3.10.10
matplotlib - 3.7.1
backtrader - 1.9.76.123

I cannot download matplotlib==3.2.2 which is one of the suggestions in this thread as a solution.

@akosmaroy
Copy link

This issue still persists, unfortunately.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet