# How To Get The Current Working Directory?

**URL:** https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754
**Category:** Maya
**Tags:** python
**Created:** [May 23, 2009, 1:55pm UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754 "2009-05-23T13:55:30Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![beast0815](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/22d042/32.png) [@beast0815](https://forum.highend3d.com/u/beast0815)
#### Post date: [May 23, 2009, 1:55pm UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754/1 "2009-05-23T13:55:30Z")

</div>

Hi,

I have developed a Plug-In for Maya. In my UI I have three pictures which are located in the scrips folder. So they are in the same folder as the sourcefiles of my Plug-In. But if the Plug-In is installed at another system I have to find out where the script folder is located. I know normaly it is in the home directory but this is not always sure.  
Now I tried to use the "os.getcwd() " Method but I get the directory from which I opened the scene and not the directory where the sourcefiles are.  
So I thought I can readout the PYTHONPATH varibale which is located in the maya.env file. But I don’t know how to do this. At first there is the same problem with the path to this file. Secondly I don’t know if there is any way to read out the variable with python over Maya.

I would be very thankful if anyone can give me a solution to this problem.

Thanks

---

<div class="post-metadata">

### Author: ![kurianos3d](https://forum.highend3d.com/user_avatar/forum.highend3d.com/kurianos3d/32/55947_2.png) [@kurianos3d](https://forum.highend3d.com/u/kurianos3d)
#### Post date: [May 23, 2009, 3:26pm UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754/2 "2009-05-23T15:26:21Z")

</div>

simply you can use  
CODE  
sys.path[0]  
to find from where the python script is got called

---

<div class="post-metadata">

### Author: ![beast0815](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/22d042/32.png) [@beast0815](https://forum.highend3d.com/u/beast0815)
#### Post date: [May 23, 2009, 3:56pm UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754/3 "2009-05-23T15:56:48Z")

</div>

I tried

CODE  
sys.path[0]

but if I run my script in Maya I get this back:

C:\Programme\Autodesk\Maya2008\bin

But thank you anyway I’ve realy forgotten this command ![]() .

---

<div class="post-metadata">

### Author: ![beast0815](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/b/22d042/32.png) [@beast0815](https://forum.highend3d.com/u/beast0815)
#### Post date: [May 24, 2009, 11:24am UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754/4 "2009-05-24T11:24:06Z")

</div>

Oh I’m so stupid. I think I’ve tried all versions to get the path but the only thing I’ve never used is simply

CODE  
self.uiImage =‘.\uiImage.bmp’

using the relativ path. _doh_

Thank you for help.

---

<div class="post-metadata">

### Author: ![anuska](https://forum.highend3d.com/letter_avatar_proxy/v4/letter/a/4da419/32.png) [@anuska](https://forum.highend3d.com/u/anuska)
#### Post date: [May 25, 2009, 7:50am UTC](https://forum.highend3d.com/t/how-to-get-the-current-working-directory/48754/5 "2009-05-25T07:50:25Z")

</div>

I recommend using the variable \_\_file\_\_
