Kismuz / btgym

Scalable, event-driven, deep-learning-friendly backtesting library
https://kismuz.github.io/btgym/
GNU Lesser General Public License v3.0
988 stars 261 forks source link

_pickle.PicklingError: Can't pickle <class 'pandas.core.frame.Pandas'>: attribute lookup Pandas on pandas.core.frame failed #147

Closed asdfqwer2015 closed 3 years ago

asdfqwer2015 commented 3 years ago
Running environment:

python 3.6.13 matplotlib 2.0.2 btgym 0.0.8 backtrader 1.9.76.123

Files or part of package has been run:

examples/setting_up_environment_basic.ipynb

Expected behaviour:

env closed successfully

Actual behaviour:

run failed when env.close(),

系统找不到指定的路径。
Process BTgymDataFeedServer-1:
Traceback (most recent call last):
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "e:\btgym\btgym\dataserver.py", line 121, in run
    socket.bind(self.network_address)
  File "d:\miniconda3\envs\sb\lib\site-packages\zmq\sugar\socket.py", line 172, in bind
    super().bind(addr)
  File "zmq/backend/cython/socket.pyx", line 540, in zmq.backend.cython.socket.Socket.bind
  File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Address in use
系统找不到指定的路径。
系统找不到指定的路径。
Process BTgymDataFeedServer-3:
Traceback (most recent call last):
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "e:\btgym\btgym\dataserver.py", line 121, in run
    socket.bind(self.network_address)
  File "d:\miniconda3\envs\sb\lib\site-packages\zmq\sugar\socket.py", line 172, in bind
    super().bind(addr)
  File "zmq/backend/cython/socket.pyx", line 540, in zmq.backend.cython.socket.Socket.bind
  File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Address in use
系统找不到指定的路径。
Process BTgymServer-2:
Traceback (most recent call last):
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "e:\btgym\btgym\server.py", line 718, in run
    _ = self.render.render('just_render', cerebro=cerebro)
  File "e:\btgym\btgym\rendering\renderer.py", line 232, in render
    self.rgb_dict['episode'] = self.draw_episode(cerebro)
  File "e:\btgym\btgym\rendering\renderer.py", line 452, in draw_episode
    draw_process.start()
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'pandas.core.frame.Pandas'>: attribute lookup Pandas on pandas.core.frame failed
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "d:\miniconda3\envs\sb\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
Process BTgymDataFeedServer-4:
Traceback (most recent call last):
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "e:\btgym\btgym\dataserver.py", line 121, in run
    socket.bind(self.network_address)
  File "d:\miniconda3\envs\sb\lib\site-packages\zmq\sugar\socket.py", line 172, in bind
    super().bind(addr)
  File "zmq/backend/cython/socket.pyx", line 540, in zmq.backend.cython.socket.Socket.bind
  File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Address in use
系统找不到指定的路径。
Process BTgymServer-5:
Traceback (most recent call last):
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "e:\btgym\btgym\server.py", line 718, in run
    _ = self.render.render('just_render', cerebro=cerebro)
  File "e:\btgym\btgym\rendering\renderer.py", line 232, in render
    self.rgb_dict['episode'] = self.draw_episode(cerebro)
  File "e:\btgym\btgym\rendering\renderer.py", line 452, in draw_episode
    draw_process.start()
  File "d:\miniconda3\envs\sb\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\context.py", line 223, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\context.py", line 322, in _Popen
    return Popen(process_obj)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\popen_spawn_win32.py", line 65, in __init__
    reduction.dump(process_obj, to_child)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
_pickle.PicklingError: Can't pickle <class 'pandas.core.frame.Pandas'>: attribute lookup Pandas on pandas.core.frame failed
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "d:\miniconda3\envs\sb\lib\multiprocessing\spawn.py", line 105, in spawn_main
    exitcode = _main(fd)
  File "d:\miniconda3\envs\sb\lib\multiprocessing\spawn.py", line 115, in _main
    self = reduction.pickle.load(from_parent)
EOFError: Ran out of input
[I 21:15:59.098 NotebookApp] Saving file at /examples/very_basic_env_setup.ipynb
---------------------------------------------------------------------------
Again                                     Traceback (most recent call last)
<ipython-input-2-61196cc6630d> in <module>
     11 
     12 env.reset()
---> 13 env.close()

e:\btgym\btgym\envs\base.py in close(self)
    843         """
    844         self.log.debug('close.call()')
--> 845         self._stop_server()
    846         self._stop_data_server()
    847         self.log.info('Environment closed.')

e:\btgym\btgym\envs\base.py in _stop_server(self)
    559         if self.server:
    560 
--> 561             if self._force_control_mode():
    562                 # In case server is running and client side is ok:
    563                 self.socket.send_pyobj({'ctrl': '_stop'})

e:\btgym\btgym\envs\base.py in _force_control_mode(self)
    597             while 'ctrl' not in self.server_response:
    598                 self.socket.send_pyobj({'ctrl': '_done'})
--> 599                 self.server_response = self.socket.recv_pyobj()
    600                 attempt += 1
    601                 self.log.debug('FORCE CONTROL MODE attempt: {}.\nResponse: {}'.format(attempt, self.server_response))

d:\miniconda3\envs\sb\lib\site-packages\zmq\sugar\socket.py in recv_pyobj(self, flags)
    737             for any of the reasons :func:`~Socket.recv` might fail
    738         """
--> 739         msg = self.recv(flags)
    740         return self._deserialize(msg, pickle.loads)
    741 

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket.Socket.recv()

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket.Socket.recv()

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket._recv_copy()

zmq/backend/cython/socket.pyx in zmq.backend.cython.socket._recv_copy()

d:\miniconda3\envs\sb\lib\site-packages\zmq\backend\cython\checkrc.pxd in zmq.backend.cython.checkrc._check_rc()

Again: Resource temporarily unavailable
Steps to reproduce:

run this script

Kismuz commented 3 years ago

Refer to #17, #24, #34

asdfqwer2015 commented 3 years ago

Thanks for your reply. When I tried to run with same version of these libraries in ubuntu after refer to #17, it works.