# Importing files from different folder in Python?

In Python, you can use the `import` statement to import modules or files from different folders. If the file you want to import is in a different folder than the script you are running, you will need to specify the path to the file.

You can use the `sys.path.append()` function to add the path to the folder containing the file you want to import. For example, if the file is located in a folder called `my_folder` in the same directory as your script, you would use the following code to add the path to `my_folder` to the system path:

<iframe width="100%" height="315" src="https://www.youtube.com/embed/Ne8G--eynRA?si=zaACvbd2ZEsXuWX0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>

```python
import sys
sys.path.append("my_folder")
```

Then you can import the file as usual:

```python
import my_file
```

Alternatively, you can use the `PYTHONPATH` environment variable to add the path to the folder containing the file you want to import.

You can also use the `importlib.import_module()` function to import modules from different folders by providing the full path of the module.

```python
import importlib
module = importlib.import_module("path.to.my_module")
```

You can also use the `from .. import` to import module or files from different folders, if the folder is in the same parent directory as the script you are running.

```python
from ..my_folder import my_module
```

Note: use of `..` is used to go one level up in the directory hierarchy.