DzITC
DzITC

Reputation: 879

Python : Flask importing a file from current directory, but subcategory

I'm struggling to import a folder that has many engines I need to use. I'm importing from main_file.py. So I think I can use - from engines import qr_code_gen, but I need to import a class which is named _QRCode_ so I tried using - from .engines.qr_code_gen import _QRCode_, but it says "module engines was not found".

Structure:

Server/start.sh
Server/wsgi.py
Server/application/main_file.py
Server/application/engines/qr_code_gen.py
Server/application/engines/__init__.py
...

I used sys.path in main_file.py and I got -

['C:\Users\Dzitc\Desktop\winteka2', 'C:\Users\Dzitc\AppData\Local\Programs\Python\Python37\Scripts\flask.exe', 'c:\users\dzitc\appdata\local\programs\python\python37\python37.zip', 'c:\users\dzitc\appdata\local\programs\python\python37\DLLs', 'c:\users\dzitc\appdata\local\programs\python\python37\lib', 'c:\users\dzitc\appdata\local\programs\python\python37', 'C:\Users\Dzitc\AppData\Roaming\Python\Python37\site-packages', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages\win32', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages\win32\lib', 'c:\users\dzitc\appdata\local\programs\python\python37\lib\site-packages\Pythonwin']

Upvotes: 0

Views: 401

Answers (1)

Azamat Galimzhanov
Azamat Galimzhanov

Reputation: 638

Going from comments you can import engine package.

Try this then:

import engines

engines.qr_code_gen._QRCode_

Upvotes: 1

Related Questions