tvwenger / maxfield

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

Python error (?) #35

Closed elkuku closed 2 years ago

elkuku commented 2 years ago

Hello, First of all, sorry for the bad title, but I sincerely have no idea what this error is about...

I am a long time maxfield user and have created (and executed) a lot of maxfields over the past years. I even do them when on vacation and I have some spare time...

OK, that's not my issue..

The script was running fine until "something" changed on my system...

I am running Manjaro Linux so the problem is most probably some BC issue, That's just one of the reasons I hate Python...

So here is the output:

maxfield-plan /path/to/waypoints.txt --outdir /path/to/dir --num_agents 1 --output_csv --num_cpus 0 --num_field_iterations 100 --max_route_solutions 100 --skip_step_plots --verbose > /path/to/log.txt

Traceback (most recent call last):
  File "/usr/bin/maxfield-plan", line 4, in <module>
    __import__('pkg_resources').run_script('maxfield==4.0', 'maxfield-plan')
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3243, in <module>
    def _initialize_master_working_set():
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3226, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3255, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 568, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 886, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 772, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'maxfield==4.0' distribution was not found and is required by the application

Since this looks oh so pythonic, I decided to go the windows way and just reinstalled the thing with python setup.py install and at least the error changed...

Traceback (most recent call last):
  File "/usr/bin/maxfield-plan", line 4, in <module>
    __import__('pkg_resources').run_script('maxfield==4.0', 'maxfield-plan')
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 651, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python3.10/site-packages/pkg_resources/__init__.py", line 1455, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg/EGG-INFO/scripts/maxfield-plan", line 29, in <module>
  File "/usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg/maxfield/maxfield.py", line 30, in <module>
  File "/usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg/maxfield/plan.py", line 35, in <module>
  File "/usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg/maxfield/router.py", line 32, in <module>
  File "/usr/lib/python3.10/site-packages/ortools-9.2.9972-py3.10-linux-x86_64.egg/ortools/constraint_solver/routing_enums_pb2.py", line 21, in <module>
    _FIRSTSOLUTIONSTRATEGY = DESCRIPTOR.message_types_by_name['FirstSolutionStrategy']
AttributeError: 'NoneType' object has no attribute 'message_types_by_name'

You may have noticed that I am not a big fan of Python or her cryptic error messages so I hope that you just say "AHA" and fix the thingy ;)

I don't think that the waypoints file is the problem since I tried various that worked before so I omit it here.

P.S.: While I am here let me first thank you for your work on this.

Second, I have created a kind of "front end" in PHP: https://github.com/elkuku/Frox which I use only on my machine to manage my own portal list.

And another thing in JS here; https://github.com/elkuku/maptest with a (working) demo here: https://elkuku.github.io/maptest/ The thing here is to convert the whole maxfield plan (the "farm keys" list and the "links" list) to a GPX file (which is done by the PHP script above) and then display it on a map with your actual location. To be used when executing the maxfield out in the field. This could also be loaded into a navigator so you can at least navigate to the portals when playing in unknown areas ;) (not tested)

So, thanks again for your hard work and I hope that you are still playing Ingress.

Sukhumi commented 2 years ago

Had the same issue, downgrade ortools and install again: sudo pip install ortools==8.2.8710

elkuku commented 2 years ago

Had the same issue, downgrade ortools and install again: sudo pip install ortools==8.2.8710

Wow that sounds like a plan :) Unfortunally just copy and pasting the command gave me the following result:

$ sudo pip install ortools==8.2.8710
ERROR: Could not find a version that satisfies the requirement ortools==8.2.8710
ERROR: No matching distribution found for ortools==8.2.8710

OK let's investigate in Python land... ortools from google... the version you mention seems to be this one and looking at the assets, the version numer seems to be right, so... no typo... let's find out the available versions... search the web, found a SO answer that tells me that there are actually five different ways to do this, depending on your pip version... for my version (21.0) teh command seems to be: pip install --use-deprecated=legacy-resolver ortools==- sounds awesome... The result was:

$ sudo pip install --use-deprecated=legacy-resolver ortools==
ERROR: Could not find a version that satisfies the requirement ortools== (from versions: 9.1.9490, 9.2.9972, 9.3.10459, 9.3.10497)
ERROR: No matching distribution found for ortools==

So it seems that the 8.2 version is no longer available for pip installation? Is there any other way to downgrade this lib?

Thanks ;)

tvwenger commented 2 years ago

Hey all - sorry for the long delay in responding to this!

I am able to reproduce the error with ortools, and I have submitted an issue with them: https://github.com/google/or-tools/issues/3202

I was able to run maxfield by installing an older version of ortools like @Sukhumi suggested.

@elkuku make sure you're using the latest pip:

(maxfieldenv) (base) 
[09:58:51 twenger@Jansky:~/maxfield/example]
$ pip install --upgrade pip
Requirement already satisfied: pip in /home/twenger/maxfieldenv/lib/python3.9/site-packages (22.0.4)
(maxfieldenv) (base) 
[09:58:56 twenger@Jansky:~/maxfield/example]
$ pip index versions ortools
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
ortools (9.3.10497)
Available versions: 9.3.10497, 9.3.10459, 9.2.9972, 9.1.9490, 9.0.9048, 8.2.8710, 8.1.8487, 8.0.8283, 7.8.7959
  INSTALLED: 8.2.8710
  LATEST:    9.3.10497
(maxfieldenv) (base) 
[09:59:03 twenger@Jansky:~/maxfield/example]
$ pip install ortools==8.2.8710
Requirement already satisfied: ortools==8.2.8710 in /home/twenger/maxfieldenv/lib/python3.9/site-packages (8.2.8710)
Requirement already satisfied: protobuf>=3.14.0 in /home/twenger/maxfieldenv/lib/python3.9/site-packages/protobuf-4.0.0rc2-py3.9.egg (from ortools==8.2.8710) (4.0.0rc2)
Requirement already satisfied: absl-py>=0.11 in /home/twenger/maxfieldenv/lib/python3.9/site-packages/absl_py-1.0.0-py3.9.egg (from ortools==8.2.8710) (1.0.0)
Requirement already satisfied: six in /home/twenger/maxfieldenv/lib/python3.9/site-packages/six-1.16.0-py3.9.egg (from absl-py>=0.11->ortools==8.2.8710) (1.16.0)
Requirement already satisfied: setuptools in /home/twenger/maxfieldenv/lib/python3.9/site-packages (from protobuf>=3.14.0->ortools==8.2.8710) (57.4.0)
tvwenger commented 2 years ago

Force older version of ortools: https://github.com/tvwenger/maxfield/commit/ce596043dbb85e5764744a8fb3641d2c71cf1042

elkuku commented 2 years ago
$ sudo pip install --upgrade pip
[sudo] Passwort für elkuku: 
Requirement already satisfied: pip in /usr/lib/python3.10/site-packages (21.0)
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 701 kB/s            
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.0
    Uninstalling pip-21.0:
      Successfully uninstalled pip-21.0
Successfully installed pip-22.0.4
~/r/m/example (master|✚60…) $ pip index versions ortools
WARNING: pip index is currently an experimental command. It may be removed/changed in a future release without prior warning.
ortools (9.3.10497)
Available versions: 9.3.10497, 9.3.10459, 9.2.9972, 9.1.9490
  INSTALLED: 9.3.10497
  LATEST:    9.3.10497

:(

Anything else that I might update?

Maybe a local caching issue?.....

elkuku commented 2 years ago

Force older version of ortools: ce59604

~/r/maxfield (master|✚60…) $ git pull
Von https://github.com/tvwenger/maxfield
   8fdfabf..ce59604  master     -> origin/master
 README.md | 3 +++
 setup.py  | 2 +-

~/r/maxfield (master|✚60…) [1]$ sudo python setup.py install
running install
/usr/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/usr/lib/python3.10/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing maxfield.egg-info/PKG-INFO
writing dependency_links to maxfield.egg-info/dependency_links.txt
writing requirements to maxfield.egg-info/requires.txt
writing top-level names to maxfield.egg-info/top_level.txt
reading manifest file 'maxfield.egg-info/SOURCES.txt'
adding license file 'LICENSE.md'
writing manifest file 'maxfield.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
copying maxfield/field.py -> build/lib/maxfield
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/field.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/geometry.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/maxfield.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/fielder.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/router.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/reorder.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/generator.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/__init__.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/plan.py -> build/bdist.linux-x86_64/egg/maxfield
copying build/lib/maxfield/results.py -> build/bdist.linux-x86_64/egg/maxfield
byte-compiling build/bdist.linux-x86_64/egg/maxfield/field.py to field.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/geometry.py to geometry.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/maxfield.py to maxfield.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/fielder.py to fielder.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/router.py to router.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/reorder.py to reorder.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/generator.py to generator.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/__init__.py to __init__.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/plan.py to plan.cpython-310.pyc
byte-compiling build/bdist.linux-x86_64/egg/maxfield/results.py to results.cpython-310.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
installing scripts to build/bdist.linux-x86_64/egg/EGG-INFO/scripts
running install_scripts
running build_scripts
creating build/bdist.linux-x86_64/egg/EGG-INFO/scripts
copying build/scripts-3.10/maxfield-plan -> build/bdist.linux-x86_64/egg/EGG-INFO/scripts
changing mode of build/bdist.linux-x86_64/egg/EGG-INFO/scripts/maxfield-plan to 755
copying maxfield.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying maxfield.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying maxfield.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying maxfield.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying maxfield.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist/maxfield-4.0-py3.10.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing maxfield-4.0-py3.10.egg
Removing /usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg
Copying maxfield-4.0-py3.10.egg to /usr/lib/python3.10/site-packages
maxfield 4.0 is already the active version in easy-install.pth
Installing maxfield-plan script to /usr/bin

Installed /usr/lib/python3.10/site-packages/maxfield-4.0-py3.10.egg
Processing dependencies for maxfield==4.0
Searching for ortools==8.2.8710
Reading https://pypi.org/simple/ortools/
/usr/lib/python3.10/site-packages/pkg_resources/__init__.py:116: PkgResourcesDeprecationWarning:  is an invalid version and will not be supported in a future release
  warnings.warn(
No local packages or working download links found for ortools==8.2.8710
error: Could not find suitable distribution for Requirement.parse('ortools==8.2.8710')

Seems like something is not compatible with another something...

tvwenger commented 2 years ago

Hmmm... I wonder if this is a python version problem? I'm using 3.9 and you're using 3.10. Maybe ortools 8.x isn't supported in python 3.10 considering it doesn't show up in your pip index... Worth a shot trying 3.9 in a virtual environment and seeing what happens!

elkuku commented 2 years ago

Worth a shot trying 3.9 in a virtual environment and seeing what happens!

After an hour or so I have to confess, that this is not an easy task :(

tvwenger commented 2 years ago

Alright, it looks like the problem with ortools is a dependency issue with another package, protobuf.

https://github.com/google/or-tools/issues/3202

Fix incoming...