2016-08-31 48 views
-3

當前嘗試爲pip安裝設置我的setup.py文件,或者簡單地通過python setup.py開發安裝,但是當我運行代碼時,它會錯誤地指出方法是不可迭代的,關於我的閱讀功能。'method'對象不能通過從讀取方法調用分裂線來迭代

的代碼是setup.py

from setuptools import setup, find_packages 
import os 

def read(filename): 
    with open(os.path.join(os.path.dirname(__file__), filename)) as f: 
     return f.read() 

setup(
    name='example', 
    version='1.0', 
    description='example', 
    url='https://github.com/example', 
    author='Example', 
    author_email='[email protected]', 
    packages=find_packages, 
    install_requires=read('requirements.txt').splitlines(), 
    zip_safe=False 
) 

如下最後我收到的錯誤是,

Traceback (most recent call last): 
    File "setup.py", line 16, in <module> 
install_requires=read('requirements.txt').splitlines() 
    File "C:\Python35\lib\distutils\core.py", line 108, in setup 
_setup_distribution = dist = klass(attrs) 
    File "C:\Python35\lib\site-packages\setuptools\dist.py", line 272, in __init__ 
_Distribution.__init__(self,attrs) 
    File "C:\Python35\lib\distutils\dist.py", line 281, in __init__ 
self.finalize_options() 
    File "C:\Python35\lib\site-packages\setuptools\dist.py", line 327, in finalize_options 
    ep.load()(self, ep.name, value) 
    File "C:\Python35\lib\site-packages\setuptools\dist.py", line 161, in check_packages 
    for pkgname in value: 
TypeError: 'method' object is not iterable 
+0

向我們展示整個錯誤消息,包括堆棧跟蹤。最有可能的是,你忘記了你的函數調用圓括號。 – user2357112

+0

看來一切都應該正常工作。我猜這裏有一些信息丟失 – RafaelC

+0

增加了完整的錯誤信息,該函數也在setup.py文件中定義了 –

回答

2

此行缺少呼叫你的括號需要:

packages=find_packages, 

更改爲:

packages=find_packages(), 
+0

這該死的我是一個白癡。 –