【问题标题】:Error packaging a python application to make it pip-installable打包 python 应用程序以使其可 pip 安装时出错
【发布时间】:2012-08-20 03:31:01
【问题描述】:

我是 git 新手,通过 github 部署了我的第一个 python-django 应用程序: https://github.com/staticdev/django-crud-utils

问题是,当我尝试安装它时,我得到了错误:

$ pip install -e git://github.com/staticdev/django-crud-utils.git#egg=django-crud-utils
Obtaining django-crud-utils from git+git://github.com/staticdev/django-crud-utils.git#egg=django-crud-utils
  Updating /home/static/virtualenvs/prp2/src/django-crud-utils clone
  Running setup.py egg_info for package django-crud-utils
    Traceback (most recent call last):
      File "<string>", line 14, in <module>
      File "/home/static/virtualenvs/prp2/src/django-crud-utils/setup.py", line 15, in <module>
        DESC = " ".join(__import__('crud_utils').__doc__.splitlines()).strip()
    AttributeError: 'NoneType' object has no attribute 'splitlines'
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):

  File "<string>", line 14, in <module>

  File "/home/static/virtualenvs/prp2/src/django-crud-utils/setup.py", line 15, in <module>

    DESC = " ".join(__import__('crud_utils').__doc__.splitlines()).strip()

AttributeError: 'NoneType' object has no attribute 'splitlines'

----------------------------------------
Command python setup.py egg_info failed with error code 1 in /home/static/virtualenvs/prp2/src/django-crud-utils
Storing complete log in /home/static/.pip/pip.log

有什么帮助吗? 提前谢谢。

【问题讨论】:

    标签: python django git github pip


    【解决方案1】:

    crud_utils 包上没有文档字符串,因此安装失败。

    只需在本地运行setup.py 模块,您也会遇到同样的错误:

    python setup.py
    

    将文档字符串添加到您的 crud_utils/__init__.py module:

    """Some docstring here would help"""
    

    附注您还将 .pyc 字节编译的缓存文件签入 GitHub,您可能希望删除这些文件。

    【讨论】:

    • 非常感谢,它成功了!我试图删除我之前添加的所有 .pyc 和 .*~ 文件,但它没有提交。我不知道为什么...
    • 你需要 git rm 告诉 git 你想要删除它们。
    • 我做了一个find . -name "*.pyc" -exec git rm -f {} \; 和一个find . -name "*.*~" -exec git rm -f {} \; 然后我用-a 提交了。现在一切都干净了!谢谢。
    猜你喜欢
    • 2017-05-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    • 2019-03-05
    相关资源
    最近更新 更多