Include a library in python application

情到浓时终转凉″ 提交于 2019-12-24 13:39:31

问题


I am trying to find a way to include a library in a Ubuntu/Python/PyGtk application even though It is not included in the stock python enviornment and I can't add it as a dependency in my setup.py file. The library is called pygal and does have a PIP package (No available .deb or ppa) but I was looking for a way to include it in my application. I would think I could just include the source .py files to the library but I am unsure of how to go about including it in my code. Pygal also requires the lxml python library. I can install it via pip on my machine and it works fine but didn't know if there was anyway to automate or include this in my .deb package's setup.py file. Any help or advice would be greatly appreciated.


回答1:


I think this should work though I'm not sure. You put the folder with the name pygal from the pygal egg in your application directory. You can take it from your python installation - it should have this path:

/usr/local/lib/python2.7/dist-packages/pygal-0.13.0-py2.7.egg/pygal

or if you use python 3.1

/usr/local/lib/python3.1/dist-packages/pygal-0.13.0-py3.1.egg/pygal

or download it from pipy.

You can use it like any python library:

from pygal import *



回答2:


I've actually figured out how to package this as a *deb file that I can include in my future PPA (or possibly submit to the community) that will (hopefully) cleanly install the python package on the system. I found a great write up in the Debian wiki that actually doesn't seem cryptic to a newbie like myself, oddly enough. http://wiki.debian.org/Python/Packaging#Example_1:_Python_extension



来源:https://stackoverflow.com/questions/13856528/include-a-library-in-python-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!