如何在PIP安装的其他项目中导入我的模块

时间:2014-03-14 05:34:49

标签: python virtualenv pip

如何在其他项目中导入我的模块streaming_capturestreaming_informationreport

我写了一个名为long_term_streaming_info_capture

的Python项目

然后将其安装在virtualenv环境下的新项目中。

如果我要导入StreamingCapture,我应该从long_term_streaming_info_capture.scripts.streaming_capture import StreamingCapture

致电

我可以在导入路径中使用没有文件夹脚本的long_term_streaming_info_capture.streaming_capture吗?

(develop+-)$ tree -L 3 -P "*.py"
.
├── helpers
│   ├── __init__.py
│   └── animation
│       ├── __init__.py
│       ├── animation_helper.py
│       ├── dqa_file_io.py
│       ├── dqa_telnet.py
│       ├── file_io_helper.py
│       ├── shm_controller.py
│       ├── telnet_helper.py
│       ├── test_dqa_file_io.py
│       └── test_dqa_telnet.py
├── log
├── main.py
├── report.py
├── sandbox
├── streaming_capture.py
└── streaming_information.py

项目框架

.
├── HACKING.txt
├── MANIFEST.in
├── NEWS.txt
├── README.rst
├── bootstrap.py
├── buildout.cfg
├── setup.py
└── src
    ├── long_term_streaming_info_capture
    │   ├── __init__.py
    │   ├── __init__.pyc
    │   ├── docs
    │   ├── scripts
    │   └── tests
    └── long_term_streaming_info_capture.egg-info
        ├── PKG-INFO
        ├── SOURCES.txt
        ├── dependency_links.txt
        ├── entry_points.txt
        ├── not-zip-safe
        └── top_level.txt

这是我的setup.py

from setuptools import setup, find_packages
import sys, os

here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
NEWS = open(os.path.join(here, 'NEWS.txt')).read()


version = '0.1'

install_requires = [
    # List your project dependencies here.
    # For more details, see:
    # http://packages.python.org/distribute/setuptools.html#declaring-dependencies
]


setup(name='long_term_streaming_info_capture',
    version=version,
    description="for capturing fps framerate",
    long_description=README + '\n\n' + NEWS,
    classifiers=[
      # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers
    ],
    keywords='',
    license='',
    packages=find_packages('src'),
    package_dir = {'': 'src'},include_package_data=True,
    zip_safe=False,
    install_requires=install_requires,
    entry_points={
        'console_scripts':
            ['long_term_streaming_info_capture=long_term_streaming_info_capture:main']
    }
)

0 个答案:

没有答案