sagemath / sage

Main repository of SageMath
https://www.sagemath.org
Other
1.31k stars 449 forks source link

executing runsnake should give a warning when runsnakerun is not installed #34570

Open mantepse opened 1 year ago

mantepse commented 1 year ago

On my computer:

sage: runsnake("2+2")
sage:   File "/tmp/tmpg4mbdsjc/tmp_cuj4rhcf", line 1
SyntaxError: Non-ASCII character '\xfb' in file /tmp/tmpg4mbdsjc/tmp_cuj4rhcf on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Component: performance

Issue created by migration from https://trac.sagemath.org/ticket/34570

fchapoton commented 1 year ago
comment:1

on mine

sage: runsnake("2+2")
sage: SyntaxError: Non-UTF-8 code starting with '\xfb' in file /tmp/tmpvfthum9d/tmp_6f220cad on line 2, but no encoding declared; see https://python.org/dev/peps/pep-0263/ for details
fchapoton commented 1 year ago

Description changed:

--- 
+++ 
@@ -1,7 +1,7 @@
 On my computer:

-sage: runsnake("some code") +sage: runsnake("2+2") sage: File "/tmp/tmpg4mbdsjc/tmp_cuj4rhcf", line 1 SyntaxError: Non-ASCII character '\xfb' in file /tmp/tmpg4mbdsjc/tmp_cuj4rhcf on line 1, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

mantepse commented 1 year ago
comment:2

As it turns out, I fail to make runsnake work with sage on ubuntu 2.04.1.

After sudo apt-get install runsnakerun I get

  File "/usr/bin/runsnake", line 15, in <module>
    from pkg_resources import load_entry_point
ImportError: No module named pkg_resources

Internet tells me to install python-setuptools, which then gets me

sage: runsnake("primes_first_n(1000)")
sage: Traceback (most recent call last):
  File "/usr/bin/runsnake", line 15, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3251, in <module>
    @_call_aside
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3235, in _call_aside
    f(*args, **kwargs)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3264, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 583, in _build_master
    ws.require(__requires__)
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 900, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 786, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'RunSnakeRun==2.0.5' distribution was not found and is required by the application
fchapoton commented 1 year ago
comment:3

which ubuntu ?

using python2.7 is certainly not a good idea

mantepse commented 1 year ago
comment:4
PRETTY_NAME="Ubuntu 22.04.1 LTS"
NAME="Ubuntu"
VERSION_ID="22.04"
VERSION="22.04.1 LTS (Jammy Jellyfish)"

Do you know how I can instruct ubuntu to use the correct python?

fchapoton commented 1 year ago
comment:5

there is a package python-is-python3

mantepse commented 1 year ago
comment:6

OK, I did:

sudo apt-get remove runsnakerun 
sudo apt remove python2
sudo apt autoremove 
sudo apt-get install python-is-python3 
sudo apt-get install runsnakerun 

All of these went smooth (python2 actually had no dependencies)

Now it almost works:

sage: s = SymmetricFunctions(QQ).s()
sage: runsnake("s[2,1](s[4])")
sage: 10:53:52: Debug: Adding duplicate image handler for 'PNG file'
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/wx/core.py", line 3282, in <lambda>
    lambda event: event.callable(*event.args, **event.kw) )
  File "/usr/lib/python3/dist-packages/runsnakerun/runsnake.py", line 701, in load
    self.SetModel(self.loader)
  File "/usr/lib/python3/dist-packages/runsnakerun/runsnake.py", line 738, in SetModel
    self.squareMap.SetModel(tree, self.adapter)
  File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 221, in SetModel
    self.UpdateDrawing()
  File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 247, in UpdateDrawing
    self.Draw(dc)
  File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 257, in Draw
    font = self.FontForLabels(dc)
  File "/usr/lib/python3/dist-packages/squaremap/squaremap.py", line 267, in FontForLabels
    font.SetPointSize(scale * font.GetPointSize())
TypeError: Font.SetPointSize(): argument 1 has unexpected type 'float'

(and the runsnake window contains, in particular, no graphics)

mantepse commented 1 year ago
comment:7

It seems that this is really a runsnake problem, I get the same errors by invoking runsnake directly.