I've been writing C extensions to Python for a while, but have been on other tasks for the past year or so. It looks like I'm going to come back to this soon, but in the meantime I've upgraded my Mac to Mavericks. And of course, suddenly, EEK! GDB is gone! And I can't find a startup file for LLDB (like the existing GDB version in Misc/gdbinit) that knows how to reach into the CPython interpreter and tell me about objects. (Or any easy Emacs-LLDB integration like I had with GDB.)
What's the consensus on the best way to debug C extensions now? Go build a custom GDB? Learn LLDB and write my own integration? Use some IDE that 'just does' all this? Just stop trying to do this on a Mac and do it in Linux instead?
(Just to make things even more fun, I need to do this in Python 2.6 to be compatible with our existing RHEL installations... which means I also need to fix the readline bug that causes Python 2.6 to crash on Mavericks -- and that's how I discovered these issues. Sigh.)
Related
I'm trying to use NetBeans 8.1 with Cygwin to write, compile and debug a C program. I knew nothing about C when I started this, and somehow found my way to fixing all the compiler errors. But when it came time to debug there was no debugger! Long story short, there's no gdb.exe in the Cygwin/bin directory and even a fresh install of Cygwin didn't produce one.
I tried another gcc compiler that did have gdb, but Netbeans won't use it.
I really don't know anything about debugging C in Netbeans with Cygwin. All I wanted to do was just bash my way through this one C program because I need to access a C library.
Alternatively, does anyone know if and how to run a C subroutine in python? (A vastly superior language to C/C++, in my opinion.)
I would be delighted to get access to this C library from either NetBeans or rewrite my access code in python.
Cygwin setup can install ~ 4000 packages.GDB is one of them.
Why do you think GDB should be installed by default ?
Please read:
https://cygwin.com/cygwin-ug-net/setup-net.html#setup-packages
(I wrote this before I saw matzeri's response. I still may try extending python to run code from the C library, but getting the C code I've already written to work would be vastly preferable.)
I have no idea what's going on with Cygwin's gdb, but after getting over my frustration I answered my alternative question. Turns out you can indeed call a C function from python. Extending Python with C or C++
I'll try it tomorrow and I see caveats, but if python.org has a section on it, I'm betting it can be done.
I am new to python. I am writing programs in NetBeans.
NetBeans 8.1
Python Plugin for NetBeans
Python 3.5.1
Plugin is set up for 3.5.1, instead of the default 2.7
NetBeans complains when I write the statement
print ("_ ", end='')
The error is
no viable alternative at input '='
It appears that NetBeans is checking for 2.7 syntax, instead of 3.5. I am able to run the code, so NetBeans is using 3.5 to execute.
How do I configure NetBeans so it uses the correct syntax checking?
After the recommendation of #alecxe, I reported a bug to NetBeans.
NetBeans does not support python 3.x. The plugin runs the correct version, but the IDE syntax checking is linked to 2.x.
Thank you for your report. Note that we do not officially support
Python 3.x yet. However, It is a high-importance task on our nbPython
Jira board... Marking this bug as Duplicate. Suggest you follow
Bug#229940 for notification.
PS. PyCharm is great.
The problem is reproducible on my end too. Even if the default Python Environment is set to Python3.5 and the Project Interpreter is also set to Python3.5, it still uses Python2 specific syntax checks. For example, it does not highlight the print if it is used as a statement and not function:
I don't think this particular behavior is configurable and this is a bug (I suspect the bundled Jython is used for the "live" syntax checking). You should definitely file an issue here.
External tools like PyLint might help, but it is not yet integrated.
And, just saying, PyCharm has a completely free community edition.
Note: Running windows7X64
I want to use some audio functions I have seen allot for python 2.7 like snack and such, however I'm using python 3.3. I have come across pygame.py that has some audio functions however pygame doesn't support 64bit arch yet.
So can it be done? if not do we know of any python audio integration modules that can get the job done on python 3 with a 64bit arch
Yes I can just install python 3 32bit but that seems counterproductive and unnecessarily complicated.
Thanks
Ben
You'll have to install 32-bit Python to run 32-bit extension modules. In my experience, two Python installations can live side-by-side quite nicely on Windows, as long as you make sure your environment (PYTHONPATH esp.) is set properly.
Have you tried this?
$ defaults write com.apple.versioner.python Prefer-32-Bit -bool yes
Edit: For the sake of sharing information, this will work (at least from my experience) on a Mac; however, it will not work on a Windows.
I'm trying to find a decent IDE that supports Python 3.x, and offers code completion/in-built Pydocs viewer, Mercurial integration, and SSH/SFTP support.
Anyhow, I'm trying Pydev, and I open up a .py file, it's in the Pydev perspective and the Run As doesn't offer any options. It does when you start a Pydev project, but I don't want to start a project just to edit one single Python script, lol, I want to just open a .py file and have It Just Work...
Plan 2, I try Komodo 6 Alpha 2. I actually quite like Komodo, and it's nice and snappy, offers in-built Mercurial support, as well as in-built SSH support (although it lacks SSH HTTP Proxy support, which is slightly annoying).
However, for some reason, this refuses to pick up Python 3. In Edit-Preferences-Languages, there's two option, one for Python and Python3, but the Python3 one refuses to work, with either the official Python.org binaries, or ActiveState's own ActivePython 3. Of course, I can set the "Python" interpreter to the 3.1 binary, but that's an ugly hack and breaks Python 2.x support.
So, does anybody who uses an IDE for Python have any suggestions on either of these accounts, or can you recommend an alternate IDE for Python 3.0 development?
Cheers,
Victor
Try PyCharm from JetBrains.
You did not mention these so I'm not sure if you've tried them but there are:
- Aptana (aptana.com)
- The Eric Python IDE (http://eric-ide.python-projects.org/)
- WingWare Python IDE (wingware.com)
I haven't used any of them so I don't know if they will match your needs, but I'd expected them to be pretty close as they are all mature.
As for PyCharm, I've been using it for a while and it's fine, actully I like it very much.
However I'm a Python noob and probably do not use many advanced features so YMMV.
I bought a low-end MacBook about a month ago and am finally getting around to configuring it for Python. I've done most of my Python work in Windows up until now, and am finding the choices for OS X a little daunting. It looks like there are at least five options to use for Python development:
"Stock" Apple Python
MacPython
Fink
MacPorts
roll-your-own-from-source
I'm still primarily developing for 2.5, so the stock Python is fine from a functionality standpoint. What I want to know is: why should I choose one over the other?
Update:
To clarify, I am looking for a discussion of the various options, not links to the documentation. I've marked this as a Community Wiki question, as I don't feel there is a "correct" answer. Thanks to everyone who has already commented for their insight.
One advantage I see in using the "stock" Python that's included with Mac OS X is that it makes deployment to other Macs a piece of cake. I don't know what your deployment scenario is, but for me this is important. My code has to run on any number of Macs at work, and I try to minimize the amount of work it takes to run my code on all of those systems.
I would highly recommend using MacPorts with Porticus for managing your Python installation. It takes a while to build everything, but the advantage is that whatever you build yourself will be built against the same libraries, so you won't have to futz around with statically linked shared objects, etc. if you want your Python stuff to work with Apache, PostgreSQL, etc.
If you choose to go this way, remember to install the python_select port and use it to make your system use the Python installed from MacPorts.
As an added bonus, MacPorts has packages for most main-stream Python eggs, so if you should be able to have MacPorts keep you up-to-date with the latest versions of all that stuff :)
Here's some helpful info to get you started. http://www.python.org/download/mac/
Depends what you are using python for. If you are using MacOS funitionality and things like PyObjC you are probably best of with MacPython or the python provided by Apple.
I use Python on my Mac mostly for development of server side applications which later will run on FreeBSD & Linux boxes. For that I have used fink python for a few years and ever since MacPorts python. With mac ports it is simple to add required c modules (like database driver etc). It's also easy to keep two python Versions (2.5 & 2.6 in my case) around.
I used "compile your own" python to test pre-3.0 python but generally I find managing dependencies to c modules painfull if done by hand.
Thanks to easy_install installing pure python modules is fast and easy for all the options mentioned above.
I was never very much an IDE person. For development I use command line subversion installed by MacPorts, Textmate and occasionaly Expandrive do directly access files on servers. I personally are very dependent on Bicyclerepairman for Textmade to handle my refactoring needs.
Others seem to be very happy with Eclipse & Pydev.
How about EPD from Enthought? Yes, it's large but it is a framework build and includes things like wxPython, vtk, numpy, scipy, and ipython built-in.
I recommend using Python Virtual environments, especially if you use a Timecapsule because Timecapsule will back everything up, except modules you added to Python!
Based on the number of bugs and omissions people have been encountering in Leopard python (just here on SO!), I couldn't recommend that version. e.g., see:
Why do I get wrong results for hmac in Python but not Perl?
Problems on select module on Python 2.5
I would choose MacPorts.
It does not eliminate your existing python supplied by Apple since it installs by default in /opt/local/bin (plays nice with it) and plus it is easy to download and install additional python modules (even binary modules that you need to compile!). I use Porticus GUI to maintain my MacPorts installed list of packages, including python.
In my windows environment I use Eclipse and PyDev, which works quite well together, even if it's a bit sparse. Apparently the exact same environment is available for the Mac as well, so I suggest downloading Eclipse and using the internal update software function to update PyDev with the URL http://pydev.sourceforge.net/updates/. To look further into PyDev, look here.
Apple's supplied python is quite old – my tiger install has 2.3.5. This may not be a problem for you, but you would be missing out on a lot. Also, there is a risk that Apple will update it. I'm not sure if moving from 2.3.5 to (say) 2.4 would cause code to break, but I guess it's possible. This happened to perl people recently: http://developers.slashdot.org/article.pl?sid=09/02/18/1435227
Macpython is a framework build (as is Apple's, I believe). To be honest, I'm not sure exactly what that means, but it's a prerequisite for some modules, in particular wxPython. If you get python from macports or fink, you will not be able to run wxPython (unless you run it through X11).
And guess what was forgotten by every answer here ... ActivePython.
No compilation required, even for third-party modules such as numpy, lxml, pyqt and thousands of others.
I recommend python (any python?) plus the ipython shell. My most recent experience with MacPython was MacPython 2.5, and I found IDLE frustrating to use as an editor. It's not very featureful, and its' very slow to scroll large quantities of output.