# How do i run python scripts which includes imports from other .py files in the same directory.

**URL:** <https://forum.ansible.com/t/how-do-i-run-python-scripts-which-includes-imports-from-other-py-files-in-the-same-directory/28471>\
**Category:** Ansible Developer\
**Created:** [August 30, 2018, 6:32pm UTC](https://forum.ansible.com/t/how-do-i-run-python-scripts-which-includes-imports-from-other-py-files-in-the-same-directory/28471 "2018-08-30T18:32:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Alan\_Jose](https://avatars.discourse-cdn.com/v4/letter/a/43a26b/32.png) [@Alan\_Jose](https://forum.ansible.com/u/Alan_Jose)\
**Post date:** [August 30, 2018, 6:32pm UTC](https://forum.ansible.com/t/how-do-i-run-python-scripts-which-includes-imports-from-other-py-files-in-the-same-directory/28471/1 "2018-08-30T18:32:21Z")

</div>

Hi,

I have a python script which imports other external python modules. i have copied all the .py files to a directory in the remote host. But, when i try to run the script file, it gives me an error “ImportError: No module named xyz”.  
I am executing the abc.py file via the scripy module and inside the abc.py, i am importing the xyz.py python file.

---

<div class="post-metadata">

**Author:** ![maxamillion](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/maxamillion/32/98_2.png) [@maxamillion](https://forum.ansible.com/u/maxamillion)\
**Post date:** [August 31, 2018, 9:10pm UTC](https://forum.ansible.com/t/how-do-i-run-python-scripts-which-includes-imports-from-other-py-files-in-the-same-directory/28471/2 "2018-08-31T21:10:52Z")

</div>

> Hi,
> 
> I have a python script which imports other external python modules. i have copied all the .py files to a directory in the remote host. But, when i try to run the script file, it gives me an error "ImportError: No module named xyz".  
> I am executing the abc.py file via the scripy module and inside the abc.py, i am importing the xyz.py python file.

I think this is probably a better inquiry for the Ansible users  
list[0] as this mailing list is meant for development discussions of  
Ansible itself.

Thank you and happy automating!  
-AdamM

[0] - [https://groups.google.com/forum/#!forum/ansible-project](https://groups.google.com/forum/#!forum/ansible-project)
