Reputation: 6468
I've installed and configured Jedi autocomplete v0.12.0 on Sublime Text 3 v3.1.1. In Jedi user settings, I've set python_interpreter
to point to python version in virtualenvs
.
"python_interpreter": "/home/username/.virtualenvs/cv3/bin/python"
The problem is that in /dependencies/jedi/api/environment.py
, the method _assert_safe
does not recognize the virtualenv path as safe.
def _assert_safe(executable_path, safe):
if safe and not _is_safe(executable_path):
raise InvalidPythonEnvironment(
"The python binary is potentially unsafe.")
The _assert_safe
method calls the method def _is_safe(executable_path)
which also returns false. The code in these two methods is pretty simple and I understand what is happening, I just don't see any solution. For testing purposes I added the virtualenv
Python path to PYTHONPATH
environment variable, it didn't make any difference.
Upvotes: 0
Views: 888
Reputation: 16325
Jedi checks if interpreters are safe. While it's perfectly reasonable for you to use whatever environment you want, it's a bit hard sometimes to argue if it's safe or not. You can just use create_environment(path, safe=False)
when you use Jedi, but obviously this sublime plugin doesn't allow that (but maybe should?).
IMO a better solution would be to create venv's instead of virtualenvs. Those work better with Jedi, because they are not copying the whole Python binary (which does not make a lot of sense anyway). I'm not 100% sure this helps you, but it might help some other people.
Upvotes: 0
Reputation: 6468
The only solution I could find was to launch Sublime
from terminal under the virtualenv
. In terminal:
$ workon virtualenv_name
$ subl
Now _is_safe(executable_path)
method can find virtualenv
Python executable and returns True
.
Upvotes: 1