【问题标题】:How to build a distribution file?如何构建分发文件?
【发布时间】:2013-02-04 06:51:41
【问题描述】:

我已经创建了setup.py 文件。但是不知道怎么分发?

书上说打开一个终端窗口并输入一个命令:python3 setup.py sdist。我这样做了,但总是出错!

我觉得代码还可以,因为只是书中的例子。我猜这个错误来自我构建发行版的方式。

在python命令行终端中,如何改变目录?

文件nester.py的代码如下:

def print_lol(the_list):
for each_item in the_list:
  if isinstance(each_item, list):
    print_lol(each_item)
  else:
    print(each_item)

setup.py文件如下:

from distutils.core import setup
setup(
  name = 'nester',
  version = '1.0.0',
  py_modules = ['nester'],
  author = 'hfpython',
  author_email = 'hfpython@headfirstlabs.com',
  url = 'http://www.headfirstlabs.com',
  description = 'A simple printer of nested lists',
)

我输入的命令是:python3 setup.py sdist 然后我得到错误:

File "<stdin>",line 1
  pythons setup.py sdist
syntaxError: invalid syntax

【问题讨论】:

标签: python setup.py


【解决方案1】:

在python命令行终端,如何切换目录?

无关紧要,因为这不应该被输入到 Python REPL 中。而是将其输入到 shell/命令提示符中。

【讨论】:

    【解决方案2】:

    如果你的c盘中没有安装python,请确保添加路径,并正确添加python文件名(python文件在安装时会根据其版本自动命名)。还要确保 setup.py 文件在 Python 文件中。

    比如我在e盘安装了我的python,版本是3.4.2。为其自动创建的文件名是 Python34。

    在命令行中,我输入:

    e:\Python34\setup.py sdist

    希望对您有所帮助。

    乔伊

    【讨论】:

      【解决方案3】:

      因为你是在windows上,所以取决于python的版本和python的安装位置

      像使用命令一样。 首先你必须清楚python的路径。

      C:\python33\python setup.py sdist

      我希望这会有所帮助。

      【讨论】:

        猜你喜欢
        • 2021-10-16
        • 2020-08-31
        • 1970-01-01
        • 2017-08-10
        • 2011-07-14
        • 2023-01-09
        • 2012-11-07
        相关资源
        最近更新 更多