开发者社区> 问答> 正文

{Python 3.8} setuptools上的pip命令错误

这是我自己的本地软件包,尝试安装它并始终收到以下错误。

C:\Users\Ron\Desktop\mypkg>pip install -e C:\Users\Ron\Desktop\mypkg
Obtaining file:///C:\Users\Ron\Desktop\mypkg
    ERROR: Command errored out with exit status 1:
     command: 'd:\python\python38-32\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Ron\\Desktop\\mypkg\\setup.py'"'"'; __file__='"'"'C:\\Users\\Ron\\Desktop\\mypkg\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info
         cwd: C:\Users\Ron\Desktop\mypkg\
    Complete output (25 lines):
    running egg_info
    writing mypkg.egg-info\PKG-INFO
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Ron\Desktop\mypkg\setup.py", line 7, in <module>
        setup(name="mypkg",
      File "d:\python\python38-32\lib\site-packages\setuptools\__init__.py", line 144, in setup
        return distutils.core.setup(\*attrs)
      File "d:\python\python38-32\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "d:\python\python38-32\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "d:\python\python38-32\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "d:\python\python38-32\lib\site-packages\setuptools\command\egg_info.py", line 290, in run
        writer(self, ep.name, os.path.join(self.egg_info, ep.name))
      File "d:\python\python38-32\lib\site-packages\setuptools\command\egg_info.py", line 622, in write_pkg_info
        metadata.write_pkg_info(cmd.egg_info)
      File "d:\python\python38-32\lib\distutils\dist.py", line 1117, in write_pkg_info
        self.write_pkg_file(pkg_info)
      File "d:\python\python38-32\lib\site-packages\setuptools\dist.py", line 164, in write_pkg_file
        long_desc = rfc822_escape(self.get_long_description())
      File "d:\python\python38-32\lib\distutils\util.py", line 475, in rfc822_escape
        lines = header.split('\n')
    AttributeError: 'function' object has no attribute 'split'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

C:\Users\Ron\Desktop\mypkg>

生成的PKG-INFO:

Metadata-Version: 2.1
Name: mypkg
Version: 0.1.0
Summary: BETA
Home-page: https://github.com/CENSURED/mypkg
License: UNKNOWN

Setup.py:

from setuptools import setup

def readme():
    with open('README.md') as file:
        return file.read()

setup(name="mypkg",
      version="0.1.0",
      description="BETA",
      long_description=readme,
      long_description_content_type="text/markdown",
      classifiers=[
          "Programming Language :: Python :: 3",
          "Operating System :: (ANY) Windows"
      ],
      url="https://github.com/CENSURED/mypkg",
      packages=setuptools.find_packages(),
      python_requires='>=3.6'
    )

--Aleadry尝试更新设置工具|||||||||||||||||||||||||||||||||||||||||| ||||||||||||||||||||||||||||| --Aleadry尝试使用setup.py模板(显然是对其进行了编辑)

问题来源:stackoverflow

展开
收起
is大龙 2020-03-24 15:35:38 1156 0
2 条回答
写回答
取消 提交回答
  • 代码改变世界,我们改变代码

    python -m pip xxxx

    2020-04-16 16:37:51
    赞同 展开评论 打赏
  • 错误的原因是因为long_description参数需要一个字符串,但是您已传入一个函数。我相信您的意图是调用函数,而不是传递函数本身:

    from setuptools import setup
    
    def readme():
        with open('README.md') as file:
            return file.read()
    
    setup(name="mypkg",
          version="0.1.0",
          description="BETA",
          long_description=readme(), # call the function here
          long_description_content_type="text/markdown",
          classifiers=[
              "Programming Language :: Python :: 3",
              "Operating System :: (ANY) Windows"
          ],
          url="https://github.com/CENSURED/mypkg",
          packages=setuptools.find_packages(),
          python_requires='>=3.6'
        )
    

    回答来源:stackoverflow

    2020-03-24 15:35:46
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载