Houdini env var windows backslash issues

   2722   2   0
User Avatar
Member
4 posts
Joined: April 2015
Offline
I have a python path env var shared across mult software applications that I also want to share for houdini and use functionality from in my pythonrc startup script.

Issue is application A, B and C require backwards slashes in the env var which I can't use to set PYTHONPATH and HSITE in my houdini.env. Everything works when hardcoding my path with forward slashes. However I want to avoid this, I also want to avoid a custom env var just for Houdini. Is there any work around to convert back slashes to forward slashes in my houdini.env?

Or is there some startup script I can set houdini env in that runs before the pythonrc? I tried setting os.environ in the pythonrc but this did not work.
User Avatar
Member
4 posts
Joined: April 2015
Offline
sys.path.append(python_path) in the pythonrc worked. I did have to have a custom env var for my hsite to run the pythonrc still. So any advice on dealing with forward slashes when working between applications would still be appreciated.
User Avatar
Member
2 posts
Joined: Nov. 2019
Offline
You can use .replace() after path.join() to ensure the slashes are correct:

print os.path.join(A,B,C).replace("\\","/")


and also Would it be better to import posixpath instead of os.path and then do posixpath.join(A, B, C) will always give you forward slashes.


The command is based on your OS,

posixpath for UNIX-style paths
ntpath for Windows paths
macpath for old-style MacOS paths
os2emxpath for OS/2 EMX paths

refer to this link :
https://docs.python.org/3.8/library/os.path.html [docs.python.org]
  • Quick Links