2017-09-27 9 views
1

파이썬 프로젝트를 패키지화하여 동료에게 배포 할 수있는 방법을 찾으려고합니다. python setup.py sdist --formats=zip을 실행하면 pip install 수있는 우편 번호를 생성하지만 파일을 실행할 때 내가 만든 클래스 파일을 가져올 수 없습니다. 여기 여러 Python 파일 패키징 : 가져 오기 오류가 발생했습니다.

프로젝트 내 파일 구조입니다 (아마도 정확하지,하지만 난 충분히 염두에 포장과 함께이 프로젝트를 구성하지 않은) :

├── README.md 
├── requirements.txt 
├── scanner 
│   ├── __init__.py 
│   ├── __pycache__ 
│   │   ├── googleSheets.cpython-35.pyc 
│   │   ├── merakiJsonHandler.cpython-35.pyc 
│   │   └── wifiTester.cpython-35.pyc 
│   ├── credentials.json 
│   ├── googleSheets.py 
│   ├── info.json 
│   ├── merakiJsonHandler.py 
│   ├── scan.py 
│   ├── whatWap.py 
│   └── wifiTester.py 
└── setup.py 

''scan.py은 '우리'의 주요 인 "스크립트는 모든 수업을 하나로 모으고 있습니다. 여기 내 setup.py의 모습입니다 : 왜 scan.py 수입 googleSheets.py하고 무엇을 내가 그와 내 기타를 가져올 수 있도록 할 할 수

Traceback (most recent call last): 
    File "//anaconda/bin/mws", line 7, in <module> 
    from scanner import scan 
    File "//anaconda/lib/python3.5/site-packages/scanner/__init__.py", line 1, in 
<module> 
    from googleSheets import SheetsController 
ImportError: No module named 'googleSheets' 

: 여기

import setuptools 

setuptools.setup(name='att-scanner', 
     version='0.1', 
     description='Meraki Wap/Wifi Scanner', 
     author='jsolum', 
     author_email='*****', 
     license='MIT', 
     packages=setuptools.find_packages(), 
     entry_points={ 
      'console_scripts' : [ 
       'mws = scanner:scan.py',],}, 
     install_requires=['pyspeedtest', 'requests', 'gspread', 'oauth2client',], 
     include_package_data=True) 

그리고 나의 오류입니다 수업?

답변

0

from googleSheets import SheetsController는 절대 import 문, 그래서 패키지가 설치되면, 당신은 패키지 이름을 사용하거나 필요

from scanner.googleSheets import SheetsController 

아니면 relative import statement

from .googleSheets import SheetsController 
+0

이 * 마른 세수 * 당신이 옳은 것을 . 내가 그걸 확인했다고 생각 했어! 현재''sys.exit (scan()) TypeError : '모듈'객체를 호출 할 수 없다는 오류가 발생합니다. 왜 scan.py를 호출하려고하는지 궁금합니다. 검사를 __main__으로 이름을 바꿀 필요가 있습니까? (내가 문제를 해결할 때 더 일찍 그것을 읽었다 고 생각한다). –

+0

@JamesSolum 나는 100 % 확실하지는 않지만, 엔트리 포인트가 모듈의 함수가 아닌 모듈에 설정된 것처럼 보입니다. 'scanner.scan : main'과 같은 것을 시도하십시오. –

+0

방금이 주석을 보았습니다. 그렇습니다. 감사! –