2017-04-25 3 views
0

내가 GitHub의에서이 OpenCV의 프로젝트에 적용하기 위해 노력하고있어 : https://github.com/andrewssobral/simple_vehicle_countingImportError를 : 없음 모듈 이름이 인쇄 회로 보드 어셈블리

나는 리눅스에서 파이썬 방법을 갔다를이 내가에 문제가있어 수입 라인입니다 :

the error message

Traceback (most recent call last): 
    File "./build/python/demo.py", line 6, in <module> 
    import bgs.pbas as pbas 
    File "/home/user/Downloads/simple_vehicle_counting-master/build/python/bgs/pbas/__init__.py", line 1, in <module> 
    from pbas import * 
ImportError: No module named pbas 

과 :

from __future__ import print_function 
import cv2 

import analysis 
import tracking 
import bgs.pbas as pbas 

마지막 줄이 오류를 일으키는 하나입니다

from pbas import * 

# noinspection PyUnresolvedReferences 
import pyboostcvconverter as pbcvt 

참고 : 인쇄 회로 보드 어셈블리의 init 파일 내부의 코드는

from analysis import * 

# noinspection PyUnresolvedReferences 
import cvb 
# noinspection PyUnresolvedReferences 
import pyboostcvconverter as pbcvt 
: 초기화 파일은 매우 유사하며,이 분석의 init 파일 경우에도 import analysis이 잘 작동 첫 번째와 같은 다른 수입
+0

내가 볼 때 bgs.pbas의'__init__' 안에 정확히하지 즉 : 모듈은 여기 가져 오기위한 파이썬 보이는 위치에 대한 자세한. 나는'import _pbas'를 본다. 왜 당신이 다른 것을 가지고 있는지 확신 할 수 없지만 그 작은 밑줄은 사물을 설명 할 수 있습니다. – RobertB

답변

1

가져 오기가 프로그램의 이름 공간에서 보이지 않으므로 from bgs.pbas import *을 수행해야합니다. 이미 bgs.pbas를 pbas로 가져 왔다는 것을 알지 못합니다.

https://docs.python.org/2/tutorial/modules.html#the-module-search-path

+0

죄송합니다. 0_0을 얻지 못했습니다. 더 설명해 주시겠습니까? 왜 '가져 오기 분석'을 쓰는 것이 좋지만 'bgs.pbas를 pbas로 가져 오기' –

+0

일지는 모르지만 그 이유를 알고 싶습니다. –

+0

@AmerAlahmar 'bgs.pbas를 pbas로 가져 오기'하는 것이 좋습니다. 그러면 bgs.pbas가 프로그램의 네임 스페이스에 pbas로 저장됩니다. Import는 프로그램의 네임 스페이스를 검사하지 않으므로 *에서 가져 오기를 원할 때 전체 이름을 사용해야합니다 :'from bgs.pbas import *','from pbas import *'. – dogoncouch

관련 문제