Hello there,
I am new to Python. In my need to learn more I am using pycharm to create a very simple project with two packages (tools and main). Both folders have __init__.py. Tools (the name is not actually 'Tools') has a .py file which has a def foo() which print 'something' and main has a .py file that imports Tools and runs Tools.foo(). In PyCharm everything works fine but when i run the main.py in max (using "python.executefile") it gives an error:
<type 'exception.ImportError'> No module named Tools
I have done a lot of internet research but i did not managed to find an answer. Any clue?
Solved! Go to Solution.
is the package or module directory location of "Tools" in the environment PYTHONPATH so that 3dsmax can know its available?
You can check by saying:
import sys for x in sys.path: print x
if it isn't, then add it in your windows environment variables.(preferred)
or temporarily you can test it and say
import sys sys.path.append( r'C:/Location/Of/Tools' )
Also, i believe max2017 doesn't rely on running python through maxscript anymore, so you can do it directly in the Python environment.
Hello there,
Thnx a lot for your useful advise. It worked BUT:
I have to import all my packages as paths in 3ds max sys.path and if i do so I will have problem with name scope since i could have Tools01.main and Tools02.main. Is there a work around except of using unique names in a single or multiple packages? I think that this destroys the power of python using packages.
Thnx in advance
P.S. relative import unfortunately does not work (from .Tools01 import main etc.) error 'Attempted relative import in non-package'
Can't find what you're looking for? Ask the community or share your knowledge.