Closed mortymacs closed 6 years ago
I would love to be able to do this as well, especially for python_package_paths
so it can pick up autocomplete for packages in the current venv
For example:
{
"python_package_paths": [
"C:\\Users\\gtalarico\\.env\\$project_name\\Lib\\site-packages",
...
@gtalarico Thank you so much, but I'm looking for $project_path
because every project has its own venv
in its root directory. PyCharm
can find it well.
oh my (: https://github.com/srusskih/SublimeJEDI/blob/master/sublime_jedi/utils.py#L311
it should be $project_path
but it is $packages
going to fix this today.
have pushed changes - 78736e3 @mortezaipo could you please check if it works for you?
@srusskih thanks for your update. Auto completion doesn't work find and I've checked the console, it shows it:
Traceback (most recent call last):
File "/opt/sublime_text/sublime_plugin.py", line 591, in on_query_completions
res = callback.on_query_completions(v, prefix, locations)
File "/home/morteza/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/completion.py", line 178, in on_query_completions
ask_daemon(view, self._show_completions, 'autocomplete', locations[0])
File "/home/morteza/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/utils.py", line 212, in ask_daemon
DAEMONS[window_id] = Daemon(view)
File "/home/morteza/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/utils.py", line 122, in __init__
self.process = self._start_process(get_settings(view))
File "/home/morteza/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi/utils.py", line 160, in _start_process
return subprocess.Popen(command, **options)
File "./python3.3/subprocess.py", line 819, in __init__
File "./python3.3/subprocess.py", line 1448, in _execute_child
FileNotFoundError: [Errno 2] No such file or directory: '$project_path/venv/bin/python'
Jedi - Python autocompletion.sublime_jedi.utils: Daemon process failed with next parameters: ['$project_path/venv/bin/python', '-B', 'daemon.py', '-p', 'uclipboard', '-f', ''] {'stdin': -1, 'bufsize': -1, 'universal_newlines': True, 'cwd': '/home/morteza/.config/sublime-text-3/Packages/Jedi - Python autocompletion/sublime_jedi', 'stderr': -1, 'stdout': -1}
It seems that $project_path
doesn't convert to the real path.
thanks. working on it.
I thought I know what I'm doing, going to write some test and review this old code (:
@mortezaipo can I ask you check jedi process for params ? Could you please do something like this and share output? Note: you need to trigger completion in sublime editor to run jedi process
$ ps ax | grep daemon.py
7280 ?? S 0:00.84 /usr/local/Cellar/python/2.7.12/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -B daemon.py -p Jedi - Python autocompletion -f required
@srusskih I've checked that, there is no background process associated to jedi
:
$ ps -x | grep -i jedi
79: 2155 pts/0 S+ 0:00 grep -n --color -i jedi
While sublime console shows it:
reloading plugin Jedi - Python autocompletion.__init__
plugins loaded
Also this is my sublime_jedi.sublime-settings
configuration file:
{
"auto_complete_function_params": "",
"python_interpreter": "$project_path/venv/bin/python"
}
sublime should run deamon.py
as a subprocess could you please try this - ps ax | grep daemon.py
?
There is no process with this name too:
$ ps ax | grep -i daemon.py
236: 4109 pts/0 S+ 0:00 grep -n --color -i daemon.py
and completion was triggered? that's odd...
what i'm trying to figure out is if the pluging uses python from settings or not.
daemon.py
should be run with a python from virtualenv.
so, when completion first time triggered, daemon should be run as a subprocess and we can find out what options was passed to
@srusskih,
Problem solved, it was my mistake.
I had to save the project file (myproject.sublime-project
). Daemon process will start successfully:
$ ps -x | grep daemon.py
106:20152 ? S 0:00 /home/morteza/Workspace/myproject/venv/bin/python -B daemon.py -p myproject -f
108:20164 pts/0 S+ 0:00 grep -n --color daemon.py
Now it works fine.
So there is no change required in your code (I've tested you commit and it shows error). This is my utils.py
file which works fine (your old code works fine):
subl_vars['$packages'] = sublime.packages_path()
try:
subl_vars['$project'] = view.window().project_file_name()
except AttributeError:
subl_vars['$project'] = get_project_file_name(view.window())
Kindly accept my apologize for this mistake. Thank you so much.
changes reverted :) happy coding :)
i'm finding a way to setup python interpreter globally, it think so boring to setup Py for each project. Pyenv gimme this file as python current active environ[1] but when i setted it on global settings it seems dont work, someone can me help me? [1] ~/.pyenv/shims/python
I've set this config in my
jedi-user
config:But it can't find installed packages on project
venv
, so auto completion doesn't work. Note: each project has its ownvenv
directory. for example:Thanks in advanced.