cpp-pybind11-playground icon indicating copy to clipboard operation
cpp-pybind11-playground copied to clipboard

Imports not working in functions, classes

Open susnicek opened this issue 4 years ago • 0 comments

Dear developers, I am new in pybind11 and I encountered following simple problem: consider the example "eval-file" - if I change the script "set-the-y.py" as follows:

import sys

def print_version():
	print(sys.version)

print_version()

set_the_answer(y - 1)

I got an error in function 'print_version'

NameError: name 'sys' is not defined

This is very strange for me, please can anybody explain me what is wrong? How to make the code above operational? Thank you in advance for your replies! Susnicek

susnicek avatar Mar 02 '21 06:03 susnicek