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/

    AttributeError: module 'backtrader' has no attribute 'Cerebro'

    General Code/Help
    2
    4
    1359
    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.
    • Ramesh Gangappa
      Ramesh Gangappa last edited by

      Initially it was working fine, all of sudden it is raising issue ...now trying on example code but the same error

      from datetime import datetime
      import backtrader as bt

      class SmaCross(bt.SignalStrategy):
      def init(self):
      sma1, sma2 = bt.ind.SMA(period=10), bt.ind.SMA(period=30)
      crossover = bt.ind.CrossOver(sma1, sma2)
      self.signal_add(bt.SIGNAL_LONG, crossover)

      cerebro = bt.Cerebro()
      cerebro.addstrategy(SmaCross)

      data0 = bt.feeds.YahooFinanceData(dataname='MSFT', fromdate=datetime(2011, 1, 1),
      todate=datetime(2012, 12, 31))
      cerebro.adddata(data0)

      cerebro.run()
      cerebro.plot()

      1 Reply Last reply Reply Quote 0
      • Ramesh Gangappa
        Ramesh Gangappa last edited by

        C:\Server\Kite Development\BackTrader>python signal.py
        Traceback (most recent call last):
        File "signal.py", line 2, in <module>
        import backtrader as bt
        File "C:\Program Files\Python37\lib\site-packages\backtrader_init_.py", line 62, in <module>
        from .cerebro import *
        File "C:\Program Files\Python37\lib\site-packages\backtrader\cerebro.py", line 27, in <module>
        import multiprocessing
        File "C:\Program Files\Python37\lib\multiprocessing_init_.py", line 16, in <module>
        from . import context
        File "C:\Program Files\Python37\lib\multiprocessing\context.py", line 5, in <module>
        from . import process
        File "C:\Program Files\Python37\lib\multiprocessing\process.py", line 18, in <module>
        import signal
        File "C:\Server\Kite Development\BackTrader\signal.py", line 10, in <module>
        cerebro = bt.Cerebro()
        AttributeError: module 'backtrader' has no attribute 'Cerebro'

        C:\Server\Kite Development\BackTrader>python --version
        Python 3.7.5

        B 1 Reply Last reply Reply Quote 0
        • B
          backtrader administrators @Ramesh Gangappa last edited by

          @Ramesh-Gangappa said in AttributeError: module 'backtrader' has no attribute 'Cerebro':

          C:\Server\Kite Development\BackTrader>python signal.py
          Traceback (most recent call last):
          File "signal.py", line 2, in <module>

          @Ramesh-Gangappa said in AttributeError: module 'backtrader' has no attribute 'Cerebro':

          File "C:\Program Files\Python37\lib\multiprocessing\process.py", line 18, in <module>
          import signal

          Your module has the same name as something which Python internals are trying to import. I actually fear you have misplaced things, but the safest bet: rename your script.

          1 Reply Last reply Reply Quote 0
          • Ramesh Gangappa
            Ramesh Gangappa last edited by

            Getting same error with module name change. I have reinstalled Python from the scratch, now problem is resolved. Thank you

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