jpeterbaker / maxfield

Code for maximizing the Ingress fields on a given set fo portals
GNU General Public License v3.0
165 stars 56 forks source link

makePlan.py script #36

Open whytecrow opened 8 years ago

whytecrow commented 8 years ago

I cannot find the script, am I the only one? Running the example gives me the "No such file or directory" error. I'm lost..

jpeterbaker commented 8 years ago

You're right. I thought I corrected the documentation when "makePlan.py" was renamed "maxfield.py". I'll fix it now. Thanks!

whytecrow commented 8 years ago

Thanks for a quick reply, anyway, the script fails with complaints about parentheses. I think it's due recent python version (3.5) - obviously the print statement needs the arguments closed in parentheses. After correcting that, the script cannot import geometry module.. This is a little bit beyond my knowledge - the file is in lib as well as the other passed to the import command.

Corrected files:

maxfield.py35.txt lib.maxfield.py35.txt

jpeterbaker commented 8 years ago

I very unwisely had two files named "maxfield.py" in the project, but since one was tucked away in lib, I thought it wouldn't matter. I've changed one to lib/makeFields.py. Get this version and make sure you're running maxfield.py and not something that's in the lib directory. Does that solve your problems?

whytecrow commented 8 years ago

No. I'm sorry to say. I didn't run the lib/maxfield.py script, either.

$ python maxfield.py -n 4 EXAMPLE.csv output/ output.pkl 
Traceback (most recent call last):
  File "maxfield.py", line 27, in <module>
    from lib import makeFields,PlanPrinter,geometry,agentOrder
  File "/home/mine/maxfield/lib/makeFields.py", line 23, in <module>
    import geometry
ImportError: No module named 'geometry'

So I added "from lib" to all imported scripts, et voila..

$ python maxfield.py -n 4 EXAMPLE.csv output/ output.pkl 
Maxfield Copyright (C) 2015 Jonathan Baker: babamots@gmail.com
Traceback (most recent call last):
  File "maxfield.py", line 251, in <module>
    sys.exit(main())
  File "maxfield.py", line 153, in main
    for i in xrange(n):
NameError: name 'xrange' is not defined
mvinni commented 8 years ago

maxfield uses python2 (2.7.11 or so). It will not work with python3.

$ python2 --version Python 2.7.11

$ python2 maxfield.py ...

whytecrow commented 8 years ago

Yeah! That's it. I didn't know that the 2.7 version was installed as well. I'll have to install 2.7 libs. xrange function was replaced by range in 3.0... Little more hacking and it will work!

jpeterbaker commented 8 years ago

Thanks! I've barely touched Python 3, but I didn't think that could be the whole problem.