First of all I want to say that although this question seems to be a duplicate of this other one I think they do not deal with the same thing and I think that the problem of that other question is different from mine. In any case, I think that one more explanation for this type of error would be enriching for the community.
import sys
sys.path.append("../CREDENTIALS")
sys.path.append("./SDK")
import consts
import client
import account_api as account
import futures_api as future
import lever_api as lever
import spot_api as spot
import swap_api as swap
import index_api as index
import option_api as option
import system_api as system
import information_api as information
import json
import datetime
import TOKENS
These imports are at the beginning of myprogram.py. This is my error message: PS C:\MYPROJECTPATH\MYPROJECT> python .\myprogram.py Traceback (most recent call last): File "C:\MYPROJECTPATH\MYPROJECT\myprogram.py", line 5, in import client File "./SDK\client.py", line 3, in from . import consts as c, utils, exceptions ImportError: attempted relative import with no known parent package
The problem is that imports into a subdirectory are not as simple in Python as other languages. There are multiple ways to do this, in your case something like this should work:
Create an
__init__.py
empty file in the SDK subdirectory (I see it's already there)And you would do the imports as follows: