如何从不同文件夹目录中的包中导入模块?

时间:2019-09-10 21:11:32

标签: python python-3.x python-import python-module pythonpath

我已经在我所有的文件夹上创建了 init .py文件,该文件实际上应该作为文件夹打包。 我不断收到“没有名为“ xxx.xxx”的模块”消息。

但是Visual Studio上的IntelliSense会显示该模块。

我尝试添加
1.在文件夹的“ init”文件上导入行
2.我要从中访问模块的主文件上的导入行
3.在主文件上'from x import y'

import os
import ml
import ml.controller
from ml import controller

Project setup on visual studio-

ProjectName
--ml(folder)
    -__init__.py
    -controller(folder)
       -__init__.py
       -classification(folder)
           -__init__.py
           -k-means.py
runserver.py
I am trying to access the k-means.py class from runserver.py.

除了将模块导入到我的主文件之外。

0 个答案:

没有答案
相关问题