# Drive letter mappings in Slicer Python

**URL:** <https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536>\
**Category:** Development\
**Created:** [July 6, 2021, 4:45pm UTC](https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536 "2021-07-06T16:45:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rohan\_n](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rohan_n/32/78474_2.png) [@rohan\_n](https://discourse.slicer.org/u/rohan_n)\
**Post date:** [July 6, 2021, 4:45pm UTC](https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536/1 "2021-07-06T16:45:08Z")

</div>

Is there an easy way to give the Slicer copy of Python access to the network drive letter mappings so that I can use something like os.path.realpath() in my Slicer modules?

Right now my local (non-Slicer) copy of Python 3.8 has no problem converting something like  
`path = r'B:\folder1`  
into a full path using  
`os.path.realpath(path)`

But I am unable to reproduce this result in Slicer’s Python Interactor.

Thanks,  
Rohan Nadkarni

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 6, 2021, 4:48pm UTC](https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536/2 "2021-07-06T16:48:28Z")

</div>

This is what I get in Slicer:

```auto
>>> import os
>>> path=r"m:\tmp"
>>> os.path.realpath(path)
'm:\\tmp'

```

Do you expect to see something different?

---

<div class="post-metadata">

**Author:** ![rohan\_n](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/rohan_n/32/78474_2.png) [@rohan\_n](https://discourse.slicer.org/u/rohan_n)\
**Post date:** [July 6, 2021, 4:51pm UTC](https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536/3 "2021-07-06T16:51:42Z")

</div>

> [@rohan\_n](#):
>
> But I am unable to reproduce this result in Slicer’s Python Interactor.

Yes, I am hoping to see the full path.  
For example, if m: stands for **\networkdrive1** , I want the os.path.realpath command to  
convert the path into **r’\\networkdrive1\tmp’**  
This is what happens when I use os.path.realpath on my non-Slicer local copy of Python and I would like Slicer Python to have the same access to these drive letter mappings.

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [July 6, 2021, 5:31pm UTC](https://discourse.slicer.org/t/drive-letter-mappings-in-slicer-python/18536/4 "2021-07-06T17:31:15Z")

</div>

Behavior of `os.path.realpath` on Windows was changed in Python 3.7 or 3.8. To resolve symlinks in a way that is compatible with a wider range of Python versions and operating systems, you can use `pathlib`:

```auto
>>> path = r"m:\tmp"
>>> import pathlib
>>> pathlib.Path(path).resolve()
WindowsPath('//SERVER01/data/tmp')

```
