sugarlabs / infoslicer

GNU General Public License v2.0
2 stars 10 forks source link

Port to Python 3 #28

Closed Aniket21mathur closed 4 years ago

Aniket21mathur commented 5 years ago

Facing problem testing this with toolkit-gtk3 (HEAD). Getting an import error for the modules of python 3 , for example from html.parser import HTMLParser, HTMLParseError ImportError: No module named html.parser. Although I checked manually python3 -c 'import html.parser' works. @quozl @pro-panda please help. Thanks!

quozl commented 5 years ago

Add a temporary debugging harness to the main program and tell me what it says in the log or stderr when you run the activity;

import sys
print >>sys.stderr, sys.version

p.s. per issue 29, unrelated to your problem, there's another copy of BeautifulSoup to consider; perhaps you should be downloading a fresh copy from the upstream project?

Aniket21mathur commented 5 years ago

Yes, I am aware of the two copies and considering both the files. This is the log-

Traceback (most recent call last):
  File "/usr/local/bin/sugar-activity", line 5, in <module>
    activityinstance.main()
  File "/usr/local/lib/python2.7/dist-packages/sugar3/activity/activityinstance.py", line 178, in main
    module = __import__(module_name)
  File "/home/aniket/activities/infoslicer/activity.py", line 33, in <module>
    import library
  File "/home/aniket/activities/infoslicer/library.py", line 34, in <module>
    import xol
  File "/home/aniket/activities/infoslicer/xol.py", line 31, in <module>
    from infoslicer.processing.NewtifulSoup import NewtifulStoneSoup \
  File "/home/aniket/activities/infoslicer/infoslicer/processing/NewtifulSoup.py", line 3, in <module>
    from BeautifulSoup import BeautifulStoneSoup
  File "/home/aniket/activities/infoslicer/infoslicer/processing/BeautifulSoup.py", line 91, in <module>
    from html.parser import HTMLParser, HTMLParseError
ImportError: No module named html.parser
quozl commented 5 years ago

Okay, it looks like you didn't add the two lines I asked for, but that doesn't matter, as the log shows me you were running the activity with Python 2, and that explains the missing html.parser module. You should use sugar-activity3 instead.

p.s. edited your comment to use block quoting of log. Please edit it to see the syntax.

Aniket21mathur commented 5 years ago

Thanks. Running sugar-activity3 gave the following trace

Traceback (most recent call last):
  File "/usr/local/bin/sugar-activity3", line 3, in <module>
    from sugar3.activity import activityinstance
ModuleNotFoundError: No module named 'sugar3'

I also tested $ python2 -c 'import sugar3' which passed. and $ python3 -c 'import sugar3' which again gave the traceback.

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named 'sugar3'

Also I checked whether the new script of toolkit-gtk3 (HEAD) is running or not. It is running which I confirmed with this warning WARNING root: Activity written for Python 2, consider porting to Python 3. being printed in log when I run the activity from master branch.

quozl commented 5 years ago

On your system, the sugar-toolkit-gtk3 sources are not built and installed for Python 3. See https://github.com/sugarlabs/sugar/pull/830 for how I did it.

Aniket21mathur commented 4 years ago

As an opportunity #31