Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port to Python 3 #28

Closed
wants to merge 1 commit into from
Closed

Port to Python 3 #28

wants to merge 1 commit into from

Conversation

Aniket21mathur
Copy link
Contributor

No description provided.

@Aniket21mathur
Copy link
Contributor Author

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
Copy link
Contributor

quozl commented May 17, 2019

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
Copy link
Contributor Author

Aniket21mathur commented May 17, 2019

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
Copy link
Contributor

quozl commented May 17, 2019

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
Copy link
Contributor Author

Aniket21mathur commented May 17, 2019

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
Copy link
Contributor

quozl commented May 17, 2019

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

@quozl quozl changed the title Port to python 3 Port to Python 3 May 29, 2019
@Aniket21mathur
Copy link
Contributor Author

As an opportunity #31

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants