gpt4 book ai didi

python - “方法”对象不能通过从读取方法调用分割线来迭代

转载 作者:行者123 更新时间:2023-12-05 09:19:53 27 4
gpt4 key购买 nike

目前正在尝试为 pip 安装设置我的 setup.py 文件或简单地安装 python setup.py develop 安装,但是当我运行代码时,它会出错,说该方法不可迭代,关于我的读取功能。

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='iam@example.com',
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

最佳答案

此行缺少您需要的调用括号:

packages=find_packages,

将其更改为:

packages=find_packages(),

关于python - “方法”对象不能通过从读取方法调用分割线来迭代,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39259819/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com