anaconda-mode
anaconda-mode copied to clipboard
Autocomplete not working in Docker venv
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
- Start the bgruening/docker-galaxy-stable container
- Navigate to a Python source file
- Use
set-variable
to setpython-shell-interpreter
to"/tool_deps/_conda/bin/python"
, which is the output of runningwhich python
in the container. - Activate the
/galaxy_venv
VirtualEnvironment usingpyvenv-activate
- Start typing something that should autocomplete (I was trying
os.p
hoping it would complete toos.path
)
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
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.
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?
You should pass additional arguments to the script.
script.py ~/.emacs.d/anaconda-mode/0.1.13 0.0.0.0 /virtual/environment/path
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
.
Hmmm can't open file
error does not look like script runs at all.
@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.