(Solved) Problem importing python module

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

(Solved) Problem importing python module

#1 Post by Enchant00 »

I'm having a problem with importing the more_itertools, specifically the collapse function.

RENPY CODE

Code: Select all

init python:
    from more_itertools import collapse
ERROR

Code: Select all

I'm sorry, but an uncaught exception occurred.

While running game code:
  File "game/romance.rpy", line 8, in script
    init python:
  File "game/romance.rpy", line 11, in <module>
    from more_itertools import collapse
SyntaxError: invalid syntax (python-packages/more_itertools/more.py, line 329)

-- Full Traceback ------------------------------------------------------------

Full traceback:
  File "game/romance.rpy", line 8, in script
    init python:
  File "D:\Renpy\renpy\ast.py", line 881, in execute
    renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
  File "D:\Renpy\renpy\python.py", line 1913, in py_exec_bytecode
    exec bytecode in globals, locals
  File "game/romance.rpy", line 11, in <module>
    from more_itertools import collapse
  File "D:\Renpy\renpy\loader.py", line 744, in load_module
    exec code in mod.__dict__
  File "python-packages/more_itertools/__init__.py", line 1, in <module>
  File "D:\Renpy\renpy\loader.py", line 743, in load_module
    code = compile(source, filename, 'exec', renpy.python.old_compile_flags, 1)
SyntaxError: invalid syntax (python-packages/more_itertools/more.py, line 329)

Windows-7-6.1.7600
Ren'Py 7.1.3.1092
Hearthrob Love Guru 1.0
Mon Mar 18 16:50:47 2019
The more_itertools is installed in my computer and works well if it's just normal python. I used the First and Third-Party Python Modules and Packages from renpy documentation hence the error.
Last edited by Enchant00 on Mon Mar 18, 2019 5:53 am, edited 2 times in total.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Problem importing python module

#2 Post by philat »

The module you linked to appears to require python 3.4 or later.

User avatar
Enchant00
Regular
Posts: 136
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Problem importing python module

#3 Post by Enchant00 »

philat wrote: Mon Mar 18, 2019 5:20 am The module you linked to appears to require python 3.4 or later.
Oh, right. Renpy uses python 2.7 while the latest update of more-itertools no longer supports python 2.7. Thanks and I'll try to see if using a prior version would work.

Post Reply

Who is online

Users browsing this forum: Rhapsy