Python3 support in Anjuta
Asked Answered
A

3

6

I have recently downloaded and installed Anjuta as a tool for Python development. I am developing in Python 3.2.3, on an Ubuntu 12.04 platform.

Following the 'Create a new project' advice on the Gnome Dev Center website I started to follow the instructions, but quickly realized that the project was using Python 2.7 (the system default).

I found a Python option under 'Edit Preferences', but changing the path to point to my required version of Python does not seem to have the desired effect. Now, every time I open Anjuta, there is a message about mis-configured paths.

I cannot find any information on the web about this.

Does anyone have any experience of setting up Anjuta for Python3? Please help!

Accalia answered 10/9, 2012 at 4:59 Comment(3)
Well then, find a better IDE that doesn't ignore the existence of Python 3, or don't use one at all. As a side note, do you really want to be tied to GNOME (which also seems to be lagging behind with Python 3 support)? My personal choice for GUI is Qt+PySide, a truly cross-platform solution.Reiser
Thanks Bla, I already use Eclipse and NetBeans, and I continue to look for something better. When I came across Anjuta being plugged on the Gnome Development site I thought it was worth finding out a bit more. When I fired it up I was pleasantly surprised at its speed and the way it interfaced with other Gnome tools. I thought I was onto something. If, as you imply, Anjuta does not support the latest version of Python that is sad, but I have to say I am not overly surprised. In my quest I have come across several IDEs that promised a lot and gave nothing when it came to Python 3.Accalia
PyCharm advertises itself as supporting Python 3, but it's not free.Tramroad
S
2

He was not asking about auto completion. Although that is a problem in of itself. The answers on this page solved neither problem for me. He is referring to the execute command. When you execute your code it doesn't always use the version of python described in the preferences or that you want for it to use. Check the top of your .py file. See where there is a shebang command

#!/usr/bin/python

change that to

#!/usr/bin/python3

or whatever path is the path to your interpreter of choice.

If this doesn't exist, place it at the top of your .py file and I can almost fully guarantee that it will fix your problem.

I hope this response comes not too late and that it can still help out the lost and confused somewhere out there.

It solved the problem for me. It took me a whole day of research and I finally figured this out by reading through the python manual at https://docs.python.org

Tons of great information in those documents, check em out!

Please let me know if this solved your problem as well.

Spaetzle answered 22/1, 2015 at 3:21 Comment(1)
Thanks, that solved it. Now doing further research on how to use virtualenv with Anjuta and load modules like pandas.Ferrand
S
1

Does the error message mention python-rope by any chance? If so, the error could be related to this library instead of python per se.. I'm on Ubuntu 12.04 and recently installed Anjuta & python3 and found a similar problem myself. I traced the error to the python-rope lib Anjuta uses for autocompletion. I have python-rope installed from the Ubuntu repos, but the installed version only works for python2, so I had to manually install the python3 port from here, and installed it with 'sudo python3 setup.py install' (inside the lib dir of course). After that Anjuta stopped complaining.

Hope this helps.

Safir answered 9/3, 2013 at 10:38 Comment(1)
Thanks for your response @chopsueysensei. From what I recall (it was several months and a couple of laptops ago) the error messages I saw were not specific enough to be useful. You may be right, as I do not have rope, even for Python 2, as I do most of my fooling around in Python 3. What you report here looks like it may well get Anjuta working with Python 3. My interests have moved beyond Gnome, so Anjuta no longer has the appeal it had for me last September. Nevertheless I have put your answer as preferred in case others wish to follow it up.Accalia
M
1

Here is how to get Python 3 autocompletion to work in Anjuta 3.4.0 running on Xubuntu 12.04:

sudo apt-get install anjuta anjuta-extras python3 python3-pkg-resources

Download the latest version of rope for python3 from here: https://pypi.python.org/pypi/rope_py3k. Install rope (possibly adjust version number):

tar zxvf rope_py3k-0.9.4-1.tar.gz
cd rope_py3k-0.9.4-1/
sudo python3 setup.py install --prefix=/usr --install-lib=/usr/lib/python3/dist-packages
sudo ln /usr/lib/python3/dist-packages/rope_py3k-0.9.4_1-py3.2.egg-info /usr/lib/python3/dist-packages/rope-0.9.4_1-py3.2.egg-info

Now run python3 in command line and check that these statements are valid:

import rope
import pkg_resources
pkg_resources.get_distribution('rope').version

Now patch the autocomplete script to work under both Python 2 and 3 versions:

sudo nano /usr/lib/anjuta/anjuta-python-autocomplete.py

add the very first line:

from __future__ import print_function

then modify all print blahblah commands to Python 3 syntax print(blahblah). The print commands are at lines 124, 143 and 144.

Now start Anjuta and point Edit->Preferences->Python->Environment: to /usr/bin/python3. Restart Anjuta and autocompletion should work.

If more debugging is needed, try running anjuta from command line, get to the point where you expect autocompletion, and see the output in terminal. If it still complains about anjuta-python-autocomplete.py, try running this script in python3 manually.

Microsecond answered 11/7, 2013 at 18:53 Comment(1)
I have made two attempts to edit this to correct the errors, both of which were rejected. Seems I have no choice but to leave a long comment. Basically, this recipe worked, but the link command is wrong on two counts (you can't have a hard link to a directory, and the directory name is wrong anyway - the consequence of cut-and-paste). Also, if there is no Python project, you have to make one so the Python environment will appear in the Edit Preferences.Accalia

© 2022 - 2024 — McMap. All rights reserved.