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!
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With