我的setup.py无法运行--安装失败

2024-03-28 10:33:58 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,我花了整整一周的时间来写一个合适的setup.py,结果是这样的:

#!/usr/bin/env python

from setuptools import setup
from codecs import open
from os import path

# Get the version number
from sql_tools2 import __version__

__author__ = 'Pandu POLUAN (pepoluan)'
__copyright__ = '(C) 2015, Pandu POLUAN'
__maintainer__ = 'pepoluan'
__email__ = 'pepoluan@gmail.com'
__status__ = 'Development'
__credits__ = ['pepoluan']

here = path.abspath(path.dirname(__file__))

# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

setup(
    name='sql_tools2',
    version=__version__,
    description='Tools to manipulate and analyze SQL Queries before execution.',
    long_description=long_description,
    url='https://bitbucket.org/pepoluan/sqltools2',
    author='Pandu POLUAN',
    author_email='pepoluan@gmail.com',
    license='MPL 2.0',
    classifiers=[
        'Development Status :: 4 - Beta',
        'Intended Audience :: Developers',
        'Intended Audience :: System Administrators',
        'Programming Language :: SQL',
        'Topic :: Software Development :: Quality Assurance',
        'Topic :: Database',
        'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
        'Programming Language :: Python :: 2',
        'Programming Language :: Python :: 2.7'
    ],
    keywords='sql subquery',
    packages=['sql_tools2'],
    install_requires=['sqlparse'],
    extras_require={
        'dev': ['pytest'],
        'test': ['pytest'],
    },
    zip_safe=False
)

现在,如果我执行setup.py install,我会看到正在安装的模块。你知道吗

但是,另一个Python程序(相同的virtualenv)无法导入:

>>> import sql_tools2
ImportError: no module named sql_tools2

我正在使用PyCharm作为IDE。有趣的是,如果我键入import并等待自动完成,PyCharm确实提供了sql_tools2作为它识别的模块之一。你知道吗

我哪里出错了?你知道吗


Tags: thepathfromimportsqlversionsetupdescription