# How to import a .py file from a directory

**URL:** <https://discourse.jupyter.org/t/how-to-import-a-py-file-from-a-directory/8430>\
**Category:** Meta\
**Tags:** jupyterhub\
**Created:** [March 20, 2021, 3:00am UTC](https://discourse.jupyter.org/t/how-to-import-a-py-file-from-a-directory/8430 "2021-03-20T03:00:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrew\_Matta](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Andrew\_Matta](https://discourse.jupyter.org/u/Andrew_Matta)\
**Post date:** [March 20, 2021, 3:00am UTC](https://discourse.jupyter.org/t/how-to-import-a-py-file-from-a-directory/8430/1 "2021-03-20T03:00:55Z")

</div>

I am trying to import a .py file into my jupyter notebook. using the following code , but it is throwing an error. I have also included _init_.py file in the directory

```
import sys 
import os
sys.path.append(os.path.abspath("/Users/hp/Documents/AFR"))
import test_standard.py

```

output  
No module named ‘test\_standard.py’; ‘test\_standard’ is not a package

---

<div class="post-metadata">

**Author:** ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)\
**Post date:** [March 20, 2021, 11:03pm UTC](https://discourse.jupyter.org/t/how-to-import-a-py-file-from-a-directory/8430/2 "2021-03-20T23:03:57Z")

</div>

Did you try the following?

```python
import test_standard

```

---

<div class="post-metadata">

**Author:** ![Andrew\_Matta](https://avatars.discourse-cdn.com/v4/letter/a/7feea3/32.png) [@Andrew\_Matta](https://discourse.jupyter.org/u/Andrew_Matta)\
**Post date:** [March 21, 2021, 2:57am UTC](https://discourse.jupyter.org/t/how-to-import-a-py-file-from-a-directory/8430/3 "2021-03-21T02:57:42Z")

</div>

Yes , it worked . Thanks
