PYTHONPATH: dev and prod
jacopo
jacopo.pecci at gmail.com
Wed Jun 12 09:29:14 EDT 2013
> 1. How you run -- 'launch' -- the code -- from py and from prod
when I have to test I use "python any_script.py" but in production there is a c++ program that is able to wrap and run python code (the technical details are a bit beyond my knowledge)
> 2. What error you get
when I run as "python any_script.py" I get
"ValueError: Attempted relative import in non-package"
I have found this explanation:
http://stackoverflow.com/questions/11536764/attempted-relative-import-in-non-package-even-with-init-py
So I have added at the top of my module:
if __name__=="__main__" and __package__ is None:
__package__="myscripts"
from ..mylib import MyClass
and I get the error:
SystemError: Parent module 'mylib' not loaded, canno perform relative import
> 3. Did you try bundling your modules into a package? What problem
> happened?
What does it mean? what does build mean in this contest? I am not compiling, I just write the .py files.
More information about the Python-list
mailing list