tvwenger / maxfield

An Ingress Linking and Fielding Strategy Generator
http://www.ingress-maxfield.com/
GNU General Public License v3.0
106 stars 56 forks source link

ImportError: cannot import name ERROR #21

Closed wubli closed 6 years ago

wubli commented 7 years ago
python2.7 makePlan.py -n 4 EXAMPLE.portals -d out/ -f output.pkl

Traceback (most recent call last):
  File "makePlan.py", line 48, in <module>
    from pebble import process, TimeoutError # to handle timeout
  File "/usr/lib/python2.7/site-packages/pebble/process/__init__.py", line 3, in <module>
    from pebble.process.pool import Pool
  File "/usr/lib/python2.7/site-packages/pebble/process/pool.py", line 24, in <module>
    from pebble import thread
  File "/usr/lib/python2.7/site-packages/pebble/thread/__init__.py", line 3, in <module>
    from pebble.thread.pool import Pool
  File "/usr/lib/python2.7/site-packages/pebble/thread/pool.py", line 21, in <module>
    from pebble.pool import ERROR, RUNNING, SLEEP_UNIT
ImportError: cannot import name ERROR

Any way to solve this?

pwiecz commented 7 years ago

I've changed the line: from pebble import process, TimeoutError # to handle timeout to:

import pebble
from concurrent.futures import TimeoutError

And:

         with process.Pool(1) as p:
            job = p.schedule(main,args=(args,),timeout=args.timeout)
         try:
            job.get()

to:

        with pebble.ProcessPool(1) as p:
             job = p.schedule(main,args=(args,),timeout=args.timeout)
         try:
            job.result()

This is causing some error messages on Windows: RuntimeError: I/O operations still in flight while destroying Overlapped object, the process may crash

but at least I can run the script

mvinni commented 7 years ago

pip2 install 'pebble==3.1.15' might also work

ghost commented 7 years ago

I comment out the line from pebble import process, TimeoutError # to handle timeout

noxdafox commented 7 years ago

Pebble has changed its interface in version 4.

I see the requirements.txt having a loose >= restriction on the package version. If the code was developed on top of Pebble3 and pip will fetch Pebble4 then you will get API mismatch.

Either restrict the requirements.txt to == 3.1.17 (the last release of Pebble3), or upgrade your code to use Pebble4. I'd recommend the second approach.

tvwenger commented 6 years ago

Fixed requirements.txt file https://github.com/tvwenger/maxfield/commit/bbe8f1c4c32703352e8bc8c90373ba0d5115fc4e