Answer the question
In order to leave comments, you need to log in
How to do any code completion with virtual environment in Sublime Text 3?
Before starting, I want to make it clear that I use PyCharm, but I have a very old 10-year-old laptop that does not pull it. That's why I want to make a micro python IDE based on Sublime Text 3 (because it's fast and doesn't mess with its installed modules in the project's virtual environment). Further to the point: I
install Sublime Text 3.
I put Package Control and install the necessary modules.
I'm used to the fact that I have a virtual environment in the v folder (and next to it are the project files themselves). My SublimeREPL installation is set up to run using just my virtual environment. And he works great.
I put Anaconda (to have auto-formatting of the code (when saving the file), linter, and I would like code completion (well, the one that appears with hints through a dot))
And auto-completion with modules from the standard library works great. But with those that I installed in my virtual environment, alas, no. Here's how to fix it?
Tried to install Jedi. Everything is exactly the same.
Where in the Anaconda package settings should I tell it to use my virtual environment?
For example, in the same SublimeREPL, I just did this in Key Binding and it works:
{
"keys": ["ctrl+b"],
"command": "repl_open",
"args": {
"cmd": ["$folder/v/Scripts/python.exe", "-i", "-u", "$file_basename"],
"cwd": "$file_path",
"encoding": "utf8",
"extend_env": {"PYTHONIOENCODING": "utf-8"},
"view_id": "*REPL* [python]",
"external_id": "python",
"syntax": "Packages/Python/Python.tmLanguage",
"type": "subprocess"
}
},
{
// You can set a path to your python virtualenv,
// for example `/home/user/.virtualenvs/myenv)`.
// Note: Interpreter path would be found automaticaly
// "python_virtualenv": "./v",
// "python_virtualenv": "./v/",
// "python_virtualenv": "v/",
// "python_virtualenv": "/v",
"python_virtualenv": "e:/py/testbot/v",
// You can set a path to your python interpreter,
// for example `/home/user/.virtualenvs/myenv/bin/python)`.
// "python_interpreter": "./v/Scripts/python",
// "python_interpreter": "v/Scripts/python",
// "python_interpreter": "./v/Scripts/python.exe",
"python_interpreter": "e:/py/testbot/v/Scripts/python",
// "sublime_completions_visibility": "all",
}
Answer the question
In order to leave comments, you need to log in
Xs who does what, and I added a couple of lines to Sublime_text\Data\Packages\Jedi - Python autocompletion\sublime_jedi\utils.py:
By the way, you need to restart after changes
And in the project file I write something like this:
{
"virtualenv": "$folder/.Venv",
"settings":
{
"python_interpreter": "$folder/.Venv/Scripts/python.exe"
},
"folders":
[
{
"path": "Path/To/My/Project"
}
]
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question