更新:setup.py
コンテンツを追加しました。
私は次のディレクトリ構造を持っています:
setup.py
packagename/
__init__.py
useless_file.py
には__init__.py
、次のものがあります。
from flask import Flask
from flask.ext.sqlalchemy import SQLAlchemy
db = SQLAlchemy()
CONFIG_FILENAME = "packagename.settings"
def create_app():
app = Flask(__name__)
app.config.from_object(CONFIG_FILENAME)
db.init_app(app)
app.register_blueprint(sms_testing)
return app
私はFlaskの推奨パッケージ構造に従いました。
ここにありsetup.py
ます:
import os
from setuptools import setup
requires = (
"flask",
"flask-sqlalchemy",
"requests>=0.13.6",
"python-dateutil>=1.5",
"twilio",
"selenium",
)
def read(fname):
return open(os.path.join(os.path.dirname(__file__), fname)).read()
setup(
name = "Package Name",
version = "0.0.1",
author = "Charles-Axel Dein",
author_email = "ca@d3in.org",
description = ("useless"),
license = "BSD",
keywords = "example documentation tutorial",
url = "http://packages.python.org/an_example_pypi_project",
packages=['package_name',],
# namespace_packages = ['package_name'],
install_requires=requires,
long_description=read('README.md'),
classifiers=[
"Development Status :: 3 - Alpha",
"Topic :: Utilities",
"License :: OSI Approved :: BSD License",
],
)
私がそうするときpython setup.py develop
、私は得る:
Traceback (most recent call last):
File "setup.py", line 2, in <module>
from setuptools import setup
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/__init__.py", line 2, in <module>
# The Python Imaging Library.
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/extension.py", line 2, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 6, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/sdist.py", line 5, in <module>
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2623, in <module>
if not len(req.specs):
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 679, in subscribe
`requirements` must be a string or a (possibly-nested) sequence
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2623, in <lambda>
if not len(req.specs):
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 2172, in activate
return pv
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1790, in declare_namespace
module.__path__ = []; _set_parent_ns(packageName)
File "/.virtualenvs/api/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1761, in _handle_ns
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 238, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/package_name/__init__.py", line 2, in <module>
import flask
File "/.virtualenvs/api/lib/python2.7/site-packages/flask/exthook.py", line 86, in load_module
raise ImportError('No module named %s' % fullname)
ImportError: No module named flask
(フォルダを編集しました)
setuptoolsが私のパッケージをインポートしようとしているので、それは論理的だと思います。これは、インストールする前にpackagename/__init__.py
これが存在する場所にインポートされます。import flask
問題は、 dbを作成するためにこれimport flask
が必要なことです。__init__.py
あなたは何をお勧めします?
ありがとう!
Chx