0

我迫切需要一个跨平台框架,因为我有大量的 .NET 产品正试图移植到 Linux。我已经开始使用 Python/pyQt 和标准库,在我尝试导入非标准库之前一切都很顺利。我听说了 pip 和 easy_install ,对此我完全感到困惑。

我的产品需要附带执行它们所需的一切,因此在 .NET 世界中,我只需将我的 DLL(或许可的 DLL)与我的产品打包在一起。

作为测试台,我正在尝试导入这个名为 requests 的库:https ://github.com/kennethreitz/requests

I've got an __init__.py file and the library source in my program directory but it isn't working. Please tell me that there is a simple way to include libraries without needing any kind of extra package installer.

4

1 回答 1

1

I would suggest you start by familiarizing yourself with python packages (see the distutils docs. Pip is simply a manager that install packages directly from the internet repository, so that you don't need to manually go and download them. So for, example, as stated under "Installing" on the requests homepage, you simply run pip install requests in a terminal, without manually downloading anything.

Packaging your product is a different story, and the way you do it depends on the target system. On windows, the easiest might be to create an installer using NSIS which will install all dependencies. You might also want to use cx-freeze to pull all the dependencies (including the python interpreter) into a single package.

On linux, many of the dependencies will already be including in most distributions. so you should just list them as requirements when creating your package (e.g. deb for ubuntu). Other dependencies might not be included in the distro's repo, but you can still list them as requirements in setup.py.

I can't really comment on Mac, since I've never used python on one, but I think that it would be similar to the linux approach.

于 2013-03-30T06:42:20.790 回答