AB-CE / abce

Agent-based computational Economics, the Python library that makes AB modelling easier

Home Page:http://abce.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OverflowError: Python int too large to convert to C long

arthurchen2018 opened this issue · comments

Hi Davoud,

Thanks for your package! I just meet a problem when I run your example called '2sectors', and this error also occurs on the jupyter tutorials.

Could you give me a hand?
Thanks

system: windows 10
python version: 3.6
I install ABCE from pip
abcEconomics-0.9.7b2

households.sell_labor()
Traceback (most recent call last):
File "C:\Users\Arthu\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 2910, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
households.sell_labor()
File "C:\Users\Arthu\Anaconda3\lib\site-packages\abcEconomics\group.py", line 59, in call
self._scheduler.do(names, command, args, kwargs)
File "C:\Users\Arthu\Anaconda3\lib\site-packages\abcEconomics\singleprocess.py", line 51, in do
ret = self.agents[name]._execute(command, args, kwargs)
File "C:\Users\Arthu\Anaconda3\lib\site-packages\abcEconomics\agent.py", line 153, in _execute
ret = getattr(self, command)(*args, **kwargs)
File "D:\AgentBasedModelComparison\household.py", line 17, in sell_labor
self.sell(('firm', self.employer), "labor", quantity=1, price=1)
File "abcEconomics\trade.pyx", line 485, in abcEconomics.trade.Trade.sell
File "abcEconomics\trade.pyx", line 121, in abcEconomics.trade.Offer.cinit
OverflowError: Python int too large to convert to C long


from tutorial:
for r in range(2):
simulation.advance_round(r)
print('Customer offers 10 dollar:')
customers.buy_drugs()
kids.print_possessions()
print('Drug Dealer accepts or rejects the offer:')
drug_dealers.sell_to_customers()
kids.print_possessions()
print()
Customer offers 10 dollar:

OverflowError Traceback (most recent call last)
in ()
2 simulation.advance_round(r)
3 print('Customer offers 10 dollar:')
----> 4 customers.buy_drugs()
5 kids.print_possessions()
6 print('Drug Dealer accepts or rejects the offer:')

~\Anaconda3\lib\site-packages\abcEconomics\group.py in call(self, *args, **kwargs)
57 def call(self, *args, **kwargs):
58 for names, command, _, __ in self.actions:
---> 59 self._scheduler.do(names, command, args, kwargs)
60 return Chain([self._scheduler.post_messages(action[0]) for action in self.actions])
61 # itertools.chain, does not work here

~\Anaconda3\lib\site-packages\abcEconomics\singleprocess.py in do(self, names, command, args, kwargs)
50 for name in names:
51 ret = self.agents[name]._execute(command, args, kwargs)
---> 52 self.rets.append(ret)
53
54 def post_messages(self, names):

~\Anaconda3\lib\site-packages\abcEconomics\agent.py in _execute(self, command, args, kwargs)
151 self._do_message_clearing()
152 self._begin_subround()
--> 153 ret = getattr(self, command)(*args, **kwargs)
154 self._end_subround()
155 self._reject_polled_but_not_accepted_offers()

in buy_drugs(self)
6 def buy_drugs(self):
7 drug_dealer_id = randrange(self.num_dealers)
----> 8 self.buy(('drug_dealer', drug_dealer_id), good='drugs', quantity=1, price=10)
9
10 def print_possessions(self):

~\Anaconda3\lib\site-packages\abcEconomics\trade.pyx in abcEconomics.trade.Trade.buy()

~\Anaconda3\lib\site-packages\abcEconomics\trade.pyx in abcEconomics.trade.Offer.cinit()

OverflowError: Python int too large to convert to C long

simulation.finalize() must be specified at the end of simulation
simulation.finalize() must be specified at the end of simulation
simulation.finalize() must be specified at the end of simulation

system: windows 10
python version: 3.6
I install ABCE from pip
abcEconomics-0.9.7b

Hi Davoud,

I suddenly fixed this issue but I don't know how it works.

First I reinstall everything and taking python version 3.8.3.
Second, instead of using pip to install abcEconomics, I just taking the Github repo.
Third, the system warns me that I need to install the package 'dataset', so I did it.

Now, I can run it on PyCharm, but perhaps you know why it is the case.

All the best,

commented

@arthurchen2018 the reason why the GitHub master version works is because it no longer has Cython code (where Cython deals with C long int). Everything is pure Python on master.