I managed to solve this problem thanks to the help of Chris and Sioheks from emacs-jedi github. Credit goes to them, tracing it to the Jedi version.
I am simply linking the discussion to emacs-jedi issue # 177 and inserting a workaround that I found, including other issues that I encountered along the way.
I used the Marmalade version, which installs a much older version. So I removed jedi and related dependencies. I installed my repository in MELPA and installed a much newer version of the Jedi. It made a team
Mx jedi:install-server
which was not before.
However, issuing this command gave an error
python-environment--make-with-runner: Program named "virtualenv" does not exist.
I made sure that I added the virtualenv location to PATH in my .bashrc. So I looked at emacs-jedi issue # 158 , which suggested installing exec-path-from-shell. I installed it from MELPA and added the lines
(when (memq window-system '(mac ns)) (exec-path-from-shell-initialize))
following instructions.
Restarting Emacs with the above lines gave an error:
Symbol function definition is void: exec-path-from-shell-initialize
So, I looked at Autoload issue # 3 when developing exec-path-from-shell (a link to this can be found in the link for emacs-jedi issue # 177). Following one of the solutions, I restarted my computer, uninstalled and reinstalled exec-path-from-shell, which magically resolved the problem that existed before the reboot.
Now I checked emacs if virtualenv can be found using
M-! which virtualenv
He gave the correct location.
Then I ran:
Mx jedi:install-server
which now seemed to run without problems. The first time there were messages about creating a default virtual environment in
/Users/XXX/.emacs.d/.python-environments
Besides
Running: pip install --upgrade /Users/XXX/.emacs.d/elpa/jedi-20140321.1323/...Done
but in subsequent tests, a pip update message was displayed.
Seeing that the server was installed without problems, I closed and restarted Emacs and opened the python script file. When I started editing, I received these messages in minibuffers:
Error (jedi): Failed to start Jedi EPC server. *** You may need to run "Mx jedi:install-server". *** This could solve the problem especially if you haven't run the command yet since Jedi.el installation or update and if the server complains about Python module imports.
and
auto-complete error: (error Server may raise an error. Use "Mx epc:pop-to-last-server-process-buffer RET" to see full traceback: /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: can't open file '/Users/XXX/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py': [Errno 2] No such file or directory` )
Thus, I realized that I needed to execute the command:
Mx jedi:install-server
every time I run Emacs before opening any python file. Then I was finally able to see the autocomplete features available during editing.
Although I can run the above command manually each time, I wanted to automate it from my .emacs when starting Emacs. It turned out that I had the following line in my .emacs
(setq jedi:server-command (list "python" "/Users/XXX/.emacs.d/elpa/jedi-0.1.2/jediepcserver.py"))
After deleting this line in my .emacs the problem disappeared and now jedi is working.