0

My Directory tree is

├── animdl.py
├── cli_session_animdl.json
├── core
│   ├── cli
│   │   ├── commands
│   │   │   ├── continuation.py
│   │   │   ├── download.py
│   │   │   ├── grab.py
│   │   │   ├── __init__.py
│   │   │   ├── __pycache__
│   │   │   │   ├── continuation.cpython-38.pyc
│   │   │   │   ├── download.cpython-38.pyc
│   │   │   │   ├── grab.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── schedule.cpython-38.pyc
│   │   │   │   ├── search.cpython-38.pyc
│   │   │   │   ├── stream.cpython-38.pyc
│   │   │   │   └── test.cpython-38.pyc
│   │   │   ├── schedule.py
│   │   │   ├── search.py
│   │   │   ├── stream.py
│   │   │   └── test.py
│   │   ├── helpers
│   │   │   ├── fun.py
│   │   │   ├── __init__.py
│   │   │   ├── player.py
│   │   │   ├── processors.py
│   │   │   ├── __pycache__
│   │   │   │   ├── fun.cpython-38.pyc
│   │   │   │   ├── __init__.cpython-38.pyc
│   │   │   │   ├── player.cpython-38.pyc
│   │   │   │   ├── processors.cpython-38.pyc
│   │   │   │   ├── searcher.cpython-38.pyc
│   │   │   │   └── sessions.cpython-38.pyc
│   │   │   ├── searcher.py
│   │   │   └── sessions.py
│   │   └── __init__.py
│   ├── codebase
│   │   ├── animefillerlist
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── associator.py
│   │   ├── downloader
│   │   │   ├── download.py
│   │   │   ├── hls_download.py
│   │   │   ├── idmanlib.py
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       ├── download.cpython-38.pyc
│   │   │       ├── hls_download.cpython-38.pyc
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── helper
│   │   │   ├── __init__.py
│   │   │   └── __pycache__
│   │   │       └── __init__.cpython-38.pyc
│   │   ├── __init__.py
│   │   └── providers
│   │       ├── anime1
│   │       │   ├── __init__.py
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── animeout
│   │       │   ├── __init__.py
│   │       │   ├── inner
│   │       │   │   ├── indexer.py
│   │       │   │   ├── __init__.py
│   │       │   │   └── __pycache__
│   │       │   │       ├── indexer.cpython-38.pyc
│   │       │   │       └── __init__.cpython-38.pyc
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── animepahe
│   │       │   ├── __init__.py
│   │       │   ├── inner
│   │       │   │   ├── decrypter.py
│   │       │   │   ├── __init__.py
│   │       │   │   └── __pycache__
│   │       │   │       ├── decrypter.cpython-38.pyc
│   │       │   │       └── __init__.cpython-38.pyc
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── animixplay
│   │       │   ├── __init__.py
│   │       │   ├── __pycache__
│   │       │   │   ├── __init__.cpython-38.pyc
│   │       │   │   └── stream_url.cpython-38.pyc
│   │       │   └── stream_url.py
│   │       ├── animtime
│   │       │   ├── __init__.py
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── gogoanime
│   │       │   ├── __init__.py
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── __init__.py
│   │       ├── nineanime
│   │       │   ├── decipher.py
│   │       │   ├── __init__.py
│   │       │   ├── inner
│   │       │   │   ├── __init__.py
│   │       │   │   ├── mp4upload.py
│   │       │   │   ├── mycloud.py
│   │       │   │   ├── __pycache__
│   │       │   │   │   ├── __init__.cpython-38.pyc
│   │       │   │   │   ├── mp4upload.cpython-38.pyc
│   │       │   │   │   ├── mycloud.cpython-38.pyc
│   │       │   │   │   ├── streamtape.cpython-38.pyc
│   │       │   │   │   └── vidstream.cpython-38.pyc
│   │       │   │   ├── streamtape.py
│   │       │   │   └── vidstream.py
│   │       │   └── __pycache__
│   │       │       ├── decipher.cpython-38.pyc
│   │       │       └── __init__.cpython-38.pyc
│   │       ├── __pycache__
│   │       │   └── __init__.cpython-38.pyc
│   │       ├── tenshimoe
│   │       │   ├── __init__.py
│   │       │   └── __pycache__
│   │       │       └── __init__.cpython-38.pyc
│   │       └── twistmoe
│   │           ├── __init__.py
│   │           ├── __pycache__
│   │           │   ├── __init__.cpython-38.pyc
│   │           │   └── stream_url.cpython-38.pyc
│   │           └── stream_url.py
│   ├── config
│   │   ├── c.py
│   │   └── __init__.py
│   ├── __init__.py
│   ├── logger.py
│   └── __version__.py
├── readme.md
└── requirements.txt

I am in directory /core/config and i have a sample file c.py(/core/config/c.py) there.i want to import a function from player.py(/core/cli/helpers/player.py). i have tried from ..cli.helpers.player import func but it doesn't seems to work i am having the following error:

ImportError: attempted relative import with no known parent package

What am i doing wrong when importing?.any help is greatly appreciated.

just_a_us3r
  • 53
  • 1
  • 2
  • 5
  • I don't think you can go `up` directories when importing. Best bet will likely be to add the target module's parent folder to `PYTHONPATH`: https://stackoverflow.com/questions/15109548/set-pythonpath-before-import-statements – Adam Smooch Aug 09 '21 at 20:29
  • 1
    This is the error message you get when running a submodule in a package directly as a script. That is not supported in Python. Change the relative imports to absolute imports, or run the submodule as main with `python -m` Duplicate of https://stackoverflow.com/q/14132789/674039 – wim Aug 09 '21 at 20:29
  • In `core/config/c.py`, if you add `sys.path.append( os.path.abspath( os.path.dirname( __file__ ) ) )`, then `core` will be in your path and you can say `from cli.helpers.player import func`. – Tim Roberts Aug 09 '21 at 20:38

0 Answers0