Skip to main content
Stack Overflow
  1. About
  2. For Teams

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

Packaging multiple Python Files: Getting Import error

I am trying to figure out how to package a python project so that I can distribute it to some co-workers. When I run python setup.py sdist --formats=zip it creates a zip that I can pip install but when I run the file it can't import the class files I created.

Here is my file structure for the project (probably not correct, but I didn't fully structure this project with packaging in mind):

├── 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'' is our "main" script that brings together all the classes. Here is what my setup.py looks like:

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)

And here is my error:

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'

Why can't scan.py import googleSheets.py and what do I do to make it import that and my other classes?

Answer*

Draft saved
Draft discarded
Cancel
3
  • facepalm you're right. I thought I checked that! Currently I am getting an error that says `` sys.exit(scan()) TypeError: 'module' object is not callable``. I am curious to why it's trying to call scan.py. Does scan need to be renamed to main? (I think I read something like that earlier when I was troubleshooting). Commented Sep 27, 2017 at 4:05
  • @JamesSolum I'm not 100% sure, but It looks like your entry point is set to the module, rather than a function in the module. Try something like scanner.scan:main Commented Sep 27, 2017 at 5:09
  • I just saw this comment now, but yes that was it! Thanks! Commented Sep 27, 2017 at 5:36

lang-py

AltStyle によって変換されたページ (->オリジナル) /