0

I have code like this:

import runpy
runpy.run_path('other.py', globals())

It works on my Windows Box with Python 3.2 but fails on the default Python3 installation (from the Repository) on my Ubuntu 10.10 machine with this message:

Traceback (most recent call last):
  File "/home/markus/Documents/projects/BlenderSerialize/generate.py", line 2, in <module>
    runpy.run_path('other.py', globals())
AttributeError: 'module' object has no attribute 'run_path'

I checked the documentation and it says that run_path was introduced in Python 2.7. What do I have to do to make this work?

trenki
  • 7,133
  • 7
  • 49
  • 61

2 Answers2

1

It was introduced in Python 2.7 and 3.2. Hence it will not work with Python 3.0 or 3.1. To make it work, use Python 2.7 or 3.2.

Lennart Regebro
  • 167,292
  • 41
  • 224
  • 251
0

When updating Python3 is not an option there is a workaround that allows one to execute a python script.

The following python code works quite well for me:

exec(compile(open("somefile.py").read(), "somefile.py", 'exec'), local_vars, global_vars)

Other examples can be found in What is an alternative to execfile in Python 3?

Community
  • 1
  • 1
trenki
  • 7,133
  • 7
  • 49
  • 61