Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/359.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在setup.cfg配置中读取时Python setuptools AttributeError_Python_Setuptools - Fatal编程技术网

在setup.cfg配置中读取时Python setuptools AttributeError

在setup.cfg配置中读取时Python setuptools AttributeError,python,setuptools,Python,Setuptools,我有以下setup.py文件: import setuptools import setuptools.config _CONFIG = setuptools.config.read_configuration('setup.cfg') setuptools.setup( **_CONFIG ) [metadata] name = Example version = 1.0.0 author = First Last author_email = first.last@ex

我有以下
setup.py
文件:

import setuptools
import setuptools.config

_CONFIG = setuptools.config.read_configuration('setup.cfg')

setuptools.setup(
    **_CONFIG
    )
[metadata]
name = Example
version = 1.0.0
author = First Last
author_email = first.last@example.com
home_page = https://www.github.com/firstlast/example
description = Example is an example project.
long_description = file: README.md
license_file = LICENSE
platform = any
keywords = example
classifiers =
  Programming Language :: Python
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Programming Language :: Python :: 3.7
  License :: Other/Proprietary License
  Operating System :: OS Independent

[options]
zip_safe = False
include_package_data = True
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*
packages =
  example
setup_requires =
  setuptools
install_requires =
  requests

[options.extras_require]
dev =
  ipython
…和
setup.cfg
文件:

import setuptools
import setuptools.config

_CONFIG = setuptools.config.read_configuration('setup.cfg')

setuptools.setup(
    **_CONFIG
    )
[metadata]
name = Example
version = 1.0.0
author = First Last
author_email = first.last@example.com
home_page = https://www.github.com/firstlast/example
description = Example is an example project.
long_description = file: README.md
license_file = LICENSE
platform = any
keywords = example
classifiers =
  Programming Language :: Python
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3.3
  Programming Language :: Python :: 3.4
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Programming Language :: Python :: 3.7
  License :: Other/Proprietary License
  Operating System :: OS Independent

[options]
zip_safe = False
include_package_data = True
python_requires = >= 2.7, != 3.0.*, != 3.1.*, != 3.2.*
packages =
  example
setup_requires =
  setuptools
install_requires =
  requests

[options.extras_require]
dev =
  ipython

为了安装模块,我正在执行以下操作:

  • 使用pipenv创建虚拟环境

  • 激活虚拟环境

    $ pipenv shell
    
    $ pip install .
    
  • 尝试在虚拟环境中安装示例模块

    $ pipenv shell
    
    $ pip install .
    

  • 当我执行步骤#3时,我得到以下错误:

    Processing /Users/firstlast/Stuff/learn/python/setuptools/example
        Complete output from command python setup.py egg_info:
        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "/private/var/folders/jw/f2zw3cls6xj20dld1h8st4jc0000gp/T/pip-req-build-rcbbm11x/setup.py", line 37, in <module>
            **_CONFIG
          File "/Users/firstlast/.local/share/virtualenvs/example-tYFXe0D0/lib/python3.7/site-packages/setuptools/__init__.py", line 140, in setup
            return distutils.core.setup(**attrs)
          File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/core.py", line 108, in setup
            _setup_distribution = dist = klass(attrs)
          File "/Users/firstlast/.local/share/virtualenvs/example-tYFXe0D0/lib/python3.7/site-packages/setuptools/dist.py", line 370, in __init__
            k: v for k, v in attrs.items()
          File "/usr/local/Cellar/python/3.7.0/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py", line 251, in __init__
            for (opt, val) in cmd_options.items():
        AttributeError: 'bool' object has no attribute 'items'
    
        ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jw/f2zw3cls6xj20dld1h8st4jc0000gp/T/pip-req-build-rcbbm11x/
    
    Processing/Users/firstlast/Stuff/learn/python/setuptools/example
    从命令python setup.py egg_info完成输出:
    回溯(最近一次呼叫最后一次):
    文件“”,第1行,在
    文件“/private/var/folders/jw/f2zw3cls6xj20dld1h8st4jc0000gp/T/pip-req-build-rcbbm11x/setup.py”,第37行,在
    **_配置
    文件“/Users/firstlast/.local/share/virtualenvs/example-tYFXe0D0/lib/python3.7/site packages/setuptools/\uuuu init\uuuuu.py”,第140行,在安装程序中
    返回distutils.core.setup(**attrs)
    文件“/usr/local/ceral/python/3.7.0/Frameworks/python.framework/Versions/3.7/lib/python3.7/distutils/core.py”,第108行,在安装程序中
    _设置\u分布=dist=klass(属性)
    文件“/Users/firstlast/.local/share/virtualenvs/example-tYFXe0D0/lib/python3.7/site packages/setuptools/dist.py”,第370行,在u init中__
    k:v表示k,属性项()中的v
    文件“/usr/local/ceral/python/3.7.0/Frameworks/python.framework/Versions/3.7/lib/python3.7/distutils/dist.py”,第251行,在__
    对于cmd_options.items()中的(opt,val):
    AttributeError:“bool”对象没有属性“items”
    ----------------------------------------
    命令“python setup.py egg_info”在/private/var/folders/jw/f2zw3cls6xj20dld1h8st4jc0000gp/T/pip-req-build-rcbbm11x中失败,错误代码为1/
    

    setuptools似乎将
    zip\u文件
    指定的值用作字典,而实际上它是一个布尔值


    有人能解释一下我做错了什么吗



    注意

    通过
    pipenv--three
    在虚拟环境中安装的Python版本是Python 3.7


    我已经确认,在虚拟环境中,setuptools是最新的(即
    pip安装--升级setuptools
    =>“需求已经是最新的:…(40.4.3)”),以及pip本身(即
    pip--版本
    ==18.0)。

    这不是
    setup.cfg
    的使用方式
    read_configuration()
    仅供希望读取
    setup.cfg
    的非setuptools代码使用;无需在您自己的
    setup.py
    中调用它,因为
    setup()
    本身执行
    setup.cfg
    的读取和处理。只需将
    setup.py
    更改为:

    import setuptools
    
    setuptools.setup()
    

    啊,太谢谢你了!对不起,我问了个愚蠢的问题。我浏览了设置工具“readthedocs”,但我发现它有点不清楚。