pythonic-emacs / anaconda-mode

Code navigation, documentation lookup and completion for Python.
GNU General Public License v3.0
707 stars 87 forks source link

Autocomplete not working in Docker venv #354

Open simpsonw opened 5 years ago

simpsonw commented 5 years ago

OS: Linux Mint 19.1 Emacs: 25.2.2 (Spacemacs master at c7a103a772d808101d7635ec10f292ab9202d9ee) anaconda-mode: 20190111.1524 docker-tramp: 20170207.325 pyenv-mode: 20170801.2348 Python: 2.7.15 Docker: 18.09.6, build 481bc77

Steps to reproduce

Expected Result

A tooltip will appear with completion options

Actual Result

Nothing changes in the UI.

*anaconda-mode* buffer

Traceback (most recent call last):
  File "<string>", line 84, in <module>
  File "/home/galaxy/.emacs.d/.cache/anaconda-mode/0.1.13/jedi-0.13.3-py2.7.egg/jedi/api/environment.py", line 342, in create_environment
    return Environment(_get_executable_path(path, safe=safe))
  File "/home/galaxy/.emacs.d/.cache/anaconda-mode/0.1.13/jedi-0.13.3-py2.7.egg/jedi/api/environment.py", line 355, in _get_executable_path
    raise InvalidPythonEnvironment("%s seems to be missing." % python)
jedi.api.environment.InvalidPythonEnvironment: /docker:6ba8c1cd8d9f:/galaxy_venv/bin/python seems to be missing.

*anaconda-socat* buffer

Process anaconda-socat killed

*anaconda-response* buffer

Not present

Notes

/galaxy_venv/bin/python does exist in the container. If run bash on the container and do /galaxy_venv/bin/activate, I'm able to successfully load the environment. I tried anaconda-mode-find-definitions in the container and it worked. On the host machine, Anaconda autocomplete works in virtual environments.

EDIT: Forgot to mention that I did set python-shell-interpreter

proofit404 commented 5 years ago

Hi, thanks for the report!

Could you try to run this script within your Docker container?

https://github.com/proofit404/anaconda-mode/blob/master/anaconda-mode.el#L70

Best regards, Artem.

simpsonw commented 5 years ago

Thanks for the response! I'm not sure I understand what I'm supposed to be doing. I copied the script to my container and attempted to run it but it complained that there weren't any arguments provided:

(galaxy_venv) (base) root@d674de68c7f6:/galaxy-central# python test.py 
Traceback (most recent call last):
  File "test.py", line 4, in <module>
    assert len(sys.argv) > 3, 'CLI arguments: %s' % sys.argv
AssertionError: CLI arguments: ['test.py']

Am I misunderstanding something? Should I be providing arguments to the script? If so, what should they be?

proofit404 commented 5 years ago

You should pass additional arguments to the script.

script.py ~/.emacs.d/anaconda-mode/0.1.13 0.0.0.0 /virtual/environment/path

simpsonw commented 5 years ago

Thanks! Here's my script output:

(galaxy_venv) (base) root@49ffdb7a334b:/galaxy-central# python ~/.emacs.d/anaconda-mode/0.1.13 0.0.0.0 /galaxy_venv
python: can't open file '/home/galaxy/.emacs.d/anaconda-mode/0.1.13': [Errno 2] No such file or directory

It occurs to me that I might actually be having an issue with pyenv-activate rather than anything related to Docker. I was working on something locally (i.e. not in Docker) yesterday and the autocomplete wasn't working for me. It works on a different local project where I'm using virtualenvwrapper and activating the virtual environment via pyenv-workon.

proofit404 commented 5 years ago

Hmmm can't open file error does not look like script runs at all.

tshu-w commented 4 years ago

@proofit404 Hi, the same issue here but in tramp mode. However I see there is an ~/.emacs.d/anaconda-mode/0.1.13 argument needed, should I install emacs on my server first? Updated: I just copy my .emacs.d to my server and run

> python script.py ~/.emacs.d/elpa/26.3/develop/anaconda-mode-20191204.111 0.0.0.0 /home/wts/.anaconda3/envs/allennlp/bin/python
anaconda_mode port 37533

however, if i run on my mac, I got this following

❯ python script.py ~/.emacs.d/anaconda-mode/0.1.13 0.0.0.0 /ssh:is:/home/wts/.anaconda3/envs/allennlp/
Traceback (most recent call last):
  File "script.py", line 61, in <module>
    virtual_environment = jedi.create_environment(virtual_environment, safe=False)
  File "/Users/wangtianshu/.emacs.d/anaconda-mode/0.1.13/jedi-0.15.1-py3.7.egg/jedi/api/environment.py", line 355, in create_environment
    return Environment(_get_executable_path(path, safe=safe))
  File "/Users/wangtianshu/.emacs.d/anaconda-mode/0.1.13/jedi-0.15.1-py3.7.egg/jedi/api/environment.py", line 368, in _get_executable_path
    raise InvalidPythonEnvironment("%s seems to be missing." % python)
jedi.api.environment.InvalidPythonEnvironment: /ssh:is:/home/wts/.anaconda3/envs/allennlp/bin/python seems to be missing.