本人试用 python 打包工具 setuptools
使用 python setup.py install 安装本地创建的测试项目 topackage:
console 的日志如下: running install running bdist_egg running egg_info writing topackage.egg-info\PKG-INFO writing dependency_links to topackage.egg-info\dependency_links.txt writing top-level names to topackage.egg-info\top_level.txt reading manifest file 'topackage.egg-info\SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'topackage.egg-info\SOURCES.txt' installing library code to build\bdist.win-amd64\egg running install_lib running build_py creating build\bdist.win-amd64\egg creating build\bdist.win-amd64\egg\pack copying build\lib\pack\prt.py -> build\bdist.win-amd64\egg\pack copying build\lib\pack_init_.py -> build\bdist.win-amd64\egg\pack byte-compiling build\bdist.win-amd64\egg\pack\prt.py to prt.cpython-35.pyc byte-compiling build\bdist.win-amd64\egg\pack_init_.py to init.cpython-35.pyc creating build\bdist.win-amd64\egg\EGG-INFO copying topackage.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO copying topackage.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO copying topackage.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO copying topackage.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO zip_safe flag not set; analyzing archive contents... creating 'dist\topackage-0.1-py3.5.egg' and adding 'build\bdist.win-amd64\egg' to it removing 'build\bdist.win-amd64\egg' (and everything under it) Processing topackage-0.1-py3.5.egg Removing d:\python35\lib\site-packages\topackage-0.1-py3.5.egg Copying topackage-0.1-py3.5.egg to d:\python35\lib\site-packages topackage 0.1 is already the active version in easy-install.pth
安装完成后: 进入 python console 界面,输入 import topackage ,提示 topackage 找不到..
1
beeeta OP + _ + 找到原因了。安装的项目,但是导入的时候不能导入项目名称而应该选择项目下的包名。
比如我这里的目录结构: topackage | ---pack |
2
beeeta OP 上一条操作失误,直接飞出去了....找不到 V2EX 的删除评论按钮...重新来一发
+ _ + 找到原因了。安装的项目,但是导入的时候不能导入项目名称而应该选择项目下的包名。 比如我这里的目录结构: topacakge | |---pack | |- prt.py | |-__init__.py |---READM.rst |---MANIFEST.in |---setup.py 安装的时候在 topackage 目录下: python setup.py install 导入包的时候使用: import pack.prt 或者 import pack ======================= 小白的青涩领域与记忆 |
3
beeeta OP 青涩领悟...
|
4
bravecarrot 2017-06-30 11:25:30 +08:00 via iPhone
倒入的包名字问题 十有八九是这样
|