如何在c中扩展python?
我擅长Python编程。我正在尝试用我自己的C程序来扩展Python。 我有一些教程,但我的操作系统非常蹩脚。它说
找不到 python.h
我也尝试过在其中进行 OpenGL 编程。 我不得不面对类似的错误
未找到 GL/gl.h
我想我的 Linux 上没有 GL dev-library
。但我非常确定 python.h 位于我的硬盘上,因为我在正确的目录中找到了它。
我使用的是 PCLinux 操作系统 2010
采用 Intel 1.8GHz Q2duo 的戴尔 Vostro 1510
2Gb 内存
gcc4.4.1
我无法在 Windows 上使用 Swig,因为我无法在其上安装 gcc。 Swig 无法在我当前的操作系统上运行。如果我自己写代码,就会出现这样的错误。 (我确信代码的完整性,因为它是一个示例文件)
请告诉我在我当前的操作系统中编译 .so
文件以扩展 python 的过程
或
请告诉我哪种操作系统最适合这种编程工作。
或
请告诉我如何将所有功能安装到 Windows 中以完成这项工作。
或
有没有一个IDE可以帮助我解决这个问题。
请帮我。为了做到这一点,我已经挠头很长时间了。 我厌倦了理想化的教程,这些教程假设理想的功能计算机一切正常。谢谢,
我不是专业程序员。但我做了一些非常有趣的事情。我已经学习了 Turbo c++.gcc
编程对我来说并不新鲜。请考虑我的新手问题。
I'm good at Python programming.I'm trying to extend python with my own c programs.
I've got some tutorials but my operating system is pretty lame. It says that
python.h is not found
Also I've tried OpenGL programming in it.
I had to face similar error
GL/gl.h not found
I think I don't have GL dev-library
on my Linux. But I'm damn sure that python.h is on my Hard drive, because I've found it in the proper directory.
I'm using PCLinux OS 2010
Dell Vostro 1510 with Intel 1.8GHz Q2duo
2Gb ram
gcc4.4.1
I can't use Swig on windows because I couldn't install gcc on it.
Swig wont run on my current OS. If I write the code by myself, it shows this kind of error.
(I'm sure of the code's integrity because it was an example file)
Please tell me the procedure to compile a .so
file for extending python in my current OS
OR
Please tell me which OS works best for this kinda programming stuff.
OR
Tell me if How I can install all the features into Windows for this work.
OR
Is there an IDE which can help me out with this kinda problem.
Please Help me. I've been scratching my head for pretty long time trying to do this.
I'm tired of idealized tutorials which assume of ideal functional computer where every thing works. Thank you
I'm not an expert programmer. But I've done some pretty interesting things. I have learn programming on turbo c++.gcc
is little new to me. Please consider my novice question.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就在 PCLinux 上编译这些东西而言,看来你确实缺少头文件。
您需要通过包管理器安装它们:
这将安装 python 标头、OpenGL 标头。
至于让这些东西在 Windows 上运行,您需要设置一个 posix 环境(cygwin 或 mingw)以便能够在那里使用 gcc,有关该主题的更多信息可以在这个问题中找到:
Cygwin 和 MinGW 有什么区别?
更新
我读了一些有关 PCLinuxOS 的内容,它似乎非常糟糕,这意味着它缺少存储库中的很多东西。
我给你的建议是使用 Ubuntu 进行开发,因为:
使用良好的开发环境可以为您节省大量时间并减少麻烦。
更新 2 在 Ubuntu 上安装标头
这将安装 python 标头、OpenGL 标头、OpenGL 实用程序标头和 OpenGL 扩展标头。
As far as compiling the stuff on PCLinux goes, it seems that you're indeed missing the header files.
You need to install them via the package manager:
This will install the python headers, the OpenGL headers.
As far as getting the stuff to run on windows goes, you'll need to setup a posix environment (either cygwin or mingw) in order to be able to use gcc there, more on that topic can be found in this question:
What is the difference between Cygwin and MinGW?
Update
I read a bit about PCLinuxOS, it seems to be pretty bad, that means it's missing a lot of stuff from its repositories.
My suggestion to you is to use Ubuntu for development since:
apt
Using a good development environment saves you a lot of time and headaches.
Update 2 Installing the headers on Ubuntu
This will install python headers, OpenGL headers, OpenGL utility headers and OpenGL extensions headers.
根据我的经验,您需要在系统上安装 Python 开发库,然后通过编写 C 代码然后使用 Python 解释器编译该 C 代码来扩展 Python。例如,请参阅文章如何扩展 Python。
In my experience, you need to have the Python development libraries installed on your system and you extend Python by writing your C code then compiling that C code using the Python interpretor. See for example the article How to extend Python.