【问题标题】:creating package with setuptools not installing properly使用 setuptools 创建软件包未正确安装
【发布时间】:2016-10-18 15:28:46
【问题描述】:

我正在使用 setuptools 尝试为 python 创建一个模块。

我尝试过在本地安装和从 git 安装 pip(版本 3.5)。 pip 表示该软件包已安装,并与“pip list”和“pip freeze”一起列在已安装的软件包中。当我尝试在脚本中导入模块时,出现导入错误“ImportError: No module named 'jackedCodeTimerPY'”。我已经把头撞在墙上一段时间了,我认为这是一个非常简单的问题,我只是错过了一些东西。

你可以在https://github.com/BebeSparkelSparkel/jackedCodeTimerPY找到我的repo

我的 setup.py 看起来像这样:

from setuptools import setup

setup(name='jackedCodeTimerPY',
      version='0.0.0',
      license='MIT',
      description='Simple but powerful code timer that can measure execution time of one line, functions, imports and gives statistics (min/max/mean/total time, number of executions).',
      author='William Rusnack',
      author_email='williamrusnack@gmail.com',
      url='https://github.com/BebeSparkelSparkel/jackedCodeTimerPY',
      classifiers=['Development Status :: 2 - Pre-Alpha', 'Programming Language :: Python :: 3'],
      py_modules=["jackedCodeTimerPY"],
      install_requires=['tabulate==0.7.5'],
     )

我的目录如下所示:

LICENSE.md      jackedCodeTimerPY.py
README.md     jackedCodeTimerPY.pyc
__pycache__     setup.py
build       small.jpg
dist        t2.py
example.py      tests.py
jackedCodeTimerPY.egg-info

【问题讨论】:

    标签: python setuptools setup.py


    【解决方案1】:

    似乎对我有用:

    pip3 install git+git://github.com/BebeSparkelSparkel/jackedCodeTimerPY.git@master
    
    Cloning git://github.com/BebeSparkelSparkel/jackedCodeTimerPY.git (to master) to /tmp/pip-lq07iup9-build
    Collecting tabulate==0.7.5 (from jackedCodeTimerPY==0.0.0)
      Downloading tabulate-0.7.5.tar.gz
    Installing collected packages: tabulate, jackedCodeTimerPY
      Running setup.py install for tabulate ... done
      Running setup.py install for jackedCodeTimerPY ... done
    Successfully installed jackedCodeTimerPY-0.0.0 tabulate-0.7.5
    
    python3 -c 'from jackedCodeTimerPY import JackedTiming; print(JackedTiming)'
    
    <class 'jackedCodeTimerPY.JackedTiming'>
    

    【讨论】:

    • 顺便看看time.perf_counter()
    • 感谢您的建议。它更多的是演示项目。现在肯定是其他地方出了点问题,因为我之前一直安装的很好。
    猜你喜欢
    • 2019-07-31
    • 1970-01-01
    • 2012-12-06
    • 1970-01-01
    • 2020-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-14
    相关资源
    最近更新 更多