Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/346.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我从github克隆的包的子模块中存在未知位置错误_Python_Python Import - Fatal编程技术网

Python 我从github克隆的包的子模块中存在未知位置错误

Python 我从github克隆的包的子模块中存在未知位置错误,python,python-import,Python,Python Import,我从github克隆了一个名为OSSP的包,这是我正在进行的一个项目所需要的。我将包放在我的主源目录中。我可以成功地导入OSSP目录中的包。但是,克隆的OSSP包中的包引用了其内部的另一个子目录。一切似乎都井然有序。除了根项目目录之外的所有目录都包含一个init.py文件 从库导入utils OUT>>>导入错误:无法从“lib”(未知位置)导入名称“utils” 我的主文件(learn\u gdal.py) 从matplotlib导入pyplot作为plt 从osgeo导入gdal 从p

我从github克隆了一个名为OSSP的包,这是我正在进行的一个项目所需要的。我将包放在我的主源目录中。我可以成功地导入OSSP目录中的包。但是,克隆的OSSP包中的包引用了其内部的另一个子目录。一切似乎都井然有序。除了根项目目录之外的所有目录都包含一个init.py文件


从库导入utils
OUT>>>
导入错误:无法从“lib”(未知位置)导入名称“utils”


我的主文件(learn\u gdal.py)

从matplotlib导入pyplot作为plt
从osgeo导入gdal
从pylab导入新轴
从段导入段\图像
作为pp导入预处理
克隆包(段.py内)

从库导入utils
OUT>>
ImportError:无法从“lib”(未知位置)导入名称“utils”

我的项目文件结构如下:

│   .gitignore                                                         
│   learn_gdal.png                                                     
│   learn_gdal.py                                                      
│   segment2.py                                                        
│   showsegimg2.py                                                     
│                                                                      
└───OSSP                                                               
    │   .gitignore                                                     
    │   Algorithm_Instructions.pdf                                     
    │   classify.py                                                    
    │   LICENSE                                                        
    │   ossp_process.py                                                
    │   preprocess.py                                                  
    │   readme.md                                                      
    │   segment.py                                                     
    │   setup.py                                                       
    │   training_gui.py                                                
    │   __init__.py                                                    
    │                                                                  
    ├───build                                                          
    │   └───temp.win-amd64-3.7                                         
    │       └───Release                                                
    │           └───lib                                                
    │                   attribute_calculations.cp37-win_amd64.exp      
    │                   attribute_calculations.cp37-win_amd64.lib      
    │                   attribute_calculations.obj                     
    │                   create_clsf_raster.cp37-win_amd64.exp          
    │                   create_clsf_raster.cp37-win_amd64.lib          
    │                   create_clsf_raster.obj                         
    │                   rescale_intensity.cp37-win_amd64.exp           
    │                   rescale_intensity.cp37-win_amd64.lib           
    │                   rescale_intensity.obj                          
    │                                                                  
    ├───lib                                                            
    │   │   attribute_calculations.c                                   
    │   │   attribute_calculations.cp37-win_amd64.pyd                  
    │   │   attribute_calculations.html                                
    │   │   attribute_calculations.pyx                                 
    │   │   create_clsf_raster.c                                       
    │   │   create_clsf_raster.cp37-win_amd64.pyd                      
    │   │   create_clsf_raster.pyx                                     
    │   │   debug_tools.py                                             
    │   │   rescale_intensity.c                                        
    │   │   rescale_intensity.cp37-win_amd64.pyd                       
    │   │   rescale_intensity.html                                     
    │   │   rescale_intensity.pyx                                      
    │   │   utils.py                                                   
    │   │   __init__.py                                                
    │   │                                                              
    │   └───__pycache__                                                
    │           __init__.cpython-37.pyc                                
    │                                                                  
    ├───training_datasets                                              
    │       icebridge_v5_training_data.h5                              
    │       pan_v2_training_data.h5                                    
    │       wv02_ms_v2_training_data.h5                                
    │       wv02_ms_v3.1_training_data.h5                              
    │                                                                  
    └───__pycache__                                                    
            preprocess.cpython-37.pyc                                  
            __init__.cpython-37.pyc                                    

您使用哪个Python版本(edit:saw it:3.7)以及是否有文档说明该包是为哪个版本编写的?它是基于anaconda 3.6构建的。在我看来,OSSP是一组独立的程序,而不是作为库编写的。因此,它假定“OSSP”目录作为导入根目录包含在“sys.path”中。一个快速而肮脏的解决方案可能是在导入之前将其添加到那里。都没有解决或改变问题