Anaconda sublime text 3 настройка
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
Anaconda is a python development suite that includes autocompletion, IDE features, linting with PyLint or PyFlakes + pep8, AutoPEP8 , Vagrant and more for Sublime Text 3.
A bit of history
Anaconda was born from my need of use a single plugin to autocomplete and lint python code. There are some other really good plugins for that but them doesn't fully fit my needs so I decided to create my own using the best of them.
Anaconda is an asynchronous client-server architecture application. It starts a new server instance for any open Sublime Text window that contains Python code.
Because that architecture, anaconda can lint or complete with python interpreters different than the built-in Sublime Text 3 python interpreter (3.3). It can complete all the python code that the configured interpreter can see and lint files for that version of the interpreter.
Anaconda has been tested in Linux, Windows and Mac OS X with positive results. I don't have any way to test the plugin in Mac OS X so I depend completely on the community for this task. Several users tested the plugin in Mac OS X with really positive feedback.
The status of the plugin in the different platforms is:
You can run the plugin in profiling mode on Windows (Sublime Text doesn't support cProfile in POSIX platforms) setting the user variable anaconda_debug to profiler , then you will get a profiling support of where the plugin is spending the processor time.
Those profiles are really helpful for us to fix bugs and solve performance problems on Windows, add it to your issues reports always that you can.
Project and Python Interpreter Switching
If you change your configured python intrepreter or you just switch your project, anaconda will detect it and reload a new completion/linting/IDE server killing the old one in a total transparent way so you don't need to restart your Sublime Text 3.
Using Package Control
- Open Sublime Text Command Pallete and type "install" with no quotes
- Select "Install Package" from the dropdown box
- Type "anaconda" with no quotes, select it and press
Go to your sublime text 3 packages directory and clone the repo:
Goto and Find Usages implementations are strongly inspired in SublimeJEDI ones, SublimeJEDI is GNU LGPL v3 licensed, you can read it online.
Python interpreter settings
Anaconda will use your PATH configured python interpreter by default. You can change it just editing the python_interpreter user setting in the anaconda's default configuration file:
You can add additional python extra paths that should be used for autocompletion purposes setting a list of paths using the user setting extra_paths :
Environment hook files
If a valid environment hook config file (called .anaconda ) exists in the root of your working folder it will bet used instead of project or general anaconda configuration. A valid .anaconda hook file is as follows.
Note that only python_interpreter and extra_paths can be hooked.
Autocompletion on dot
If you want to trigger autocompletion when you write down the dot character you can setup this desirable behaviour editing your Sublime Text 3 Python.sublime-settings file in Packages/User (you may have to create this file yourself):
Word and Explicit Sublime Text 3 Completions
Some developers preffer that SublimeText 3 does not autocomplete by itself so you can disable word and explicit autocompletiond setting suppress_word_completions and suppress_explicit_completions as true .
You can choose to don't show Python snippets in your autocompletion results placing a user setting hide_snippets_on_completion as true in your settings.
Complete function and class parameters
If complete_parameters is true , anaconda will add function and class parameters to its completions when you type ( after a completion.
If complete_all_parameters is true , it will add all the possible parameters, if it's false, it will add only required parameters
No key binding is needed to use this feature so it doesn't interfere in any way with your Sublime Text 3 normal operations.
Anaconda IDE Features
With this command you can go to a file where a variable, function or class that your cursor is over is defined.
- Shortcut: Linux super+g , Mac OS X and Windows ctrl+alt+g
- Context Menu: Anaconda > Goto Definition
With this command you can find all the places where a variable, function or class where your cursor is over is being used.
- Shortcut: Linux super+f , Mac OS X and Windows ctrl+alt+f
- Context Menu: Anaconda > Find Usages
With this command you can get the docstring of whatever function or method. You can just write the function call, for example, sys.exit() and then use this command to get the function signature and docstring without lose the cursor focus from the buffer.
- Shortcut: Linux super+d , Mac OS X and Windows ctrl+alt+d
- Context Menu: Anaconda > Show Documentation
note: Context menu only works on Python code (no comments, no docstrings) note: If you set the option "display_signatures" as true , anaconda will display method signatures and other help strings in the status bar while you edit the file.
With this command you can rename the object under the cursor in a project basis scope in a safe way.
- Context Menu: Anaconda > Rename object under cursor
McCabe code complexity checker
You can run the McCabe complexity checker tool in whatever python file you want. You can configure it threshold adjusting the option setting mccabe_threshold in the configuration file or in your project configuration file.
- Context Menu: Anaconda > McCabe complexity check
Autoformat PEP8 Errors
Anaconda supports the AutoPEP8 tool and its integrated as part of the plugin itself. You can reformat your files to follow PEP8 automatically using the command palette Anaconda: Autoformat PEP8 Errors or the same option in the contextual menu. Of course this operation is performed asynchronous but it set your current buffer as read only while the operation is performed, a progress bar is shown at the status bar while working.
Anaconda can fix the following PEP8 errors
Please, take a look at the configuration file to get a list of available options.
Anaconda linting is mainly based/inspired/ported from SublimeLinter because that I added the SublimeLinter LICENSE file in the repo. Although anaconda linter is inspired in SublimeLinter, anaconda linting is much faster for serveral reasons:
- Anaconda does not use a delayed queue to perform the lintin work, instead of that we fire a single call to the linter methods n seconds after the last key was pressend by the user while typing. Those n seconds can be configured by the user.
- Anaconda is totally asynchronous so we should never block the gui, because that, our linting is smooth and flawless.
Disabling the linter
Just set the user setting anaconda_linting as false
Disabling the linter in certain files
Sometimes we have to open some file from this mate that all of us have that doesn't seems to know what PEP-8 means and when the teacher spoke about code conventions and readability of the code he was just sick in home and we are just annoyed by the linter marking everyone line of the code.
On this situations we can just disable the linting for this specific file using the command Anaconda: Disable linting on this file from the command palette.
When our mate learns how to write proper and clean code we can just turn it on again with Anaconda: Enable linting on this file .
Disabling specific PyFlakes errors
You can disable specific PyFlakes errors (unused import module for example) uncommenting it in the pyflakes_explicit_ignore list in the configuration file or adding this list to your project configuration and adding there the type of warnings/errors that you want to disable.
Showing linting error list
You can show a quick panel with all the errors in the file you are currently editing usign the command palette or the contextual menu.
Jump to the next error
You can use the Anaconda: Next lint error command from the Command Palette , from the Context Menu or just add a shortcut to the anaconda_next_lint_error to navigate trough the lint errors on the file.
Note: The order is not per line but for error severity in this order: ERRORS, WARNINGS, VIOLATIONS
- Always mode (default) - When anaconda_linting_behaviour is set as always the linting is performed in the background as you are editing the file you are working on and in load/save events. The linting process is performed in the background in another thread of execution and it doesn't block the Sublime Text GUI. The process is fired when the plugin detected that you stop typying for a period of time, by default is half a second and can be configured editign the value of the user setting anaconda_linter_delay .
- Load and Save mode - When anaconda_linting_behaviour is set as load-save linting is performed on file load and saving only.
- Save only mode - When anaconda_linting_behabiour is set as save-only linting is performed on file saving only.
If you don't care about pep8 linting (you are terribly wrong) you can disable pep8 linting at all setting the user setting pep8 as false
Disabling certain errors
If what you want to do is just disable some errors like "line too long" E501 error in pep8 (you are terribly wrong again) you can add it to the pep8_ignore user setting like:
There is an equivalen for PyFlakes errors called pyflakes_ignore , look at the default anaconda configuration file for more details.
Using PyLint as PyFlakes and pep8 alternatives
Anaconda has full support for PyLint as linter application but some considerations has to be taken before do it.
Due 3rd party dependencies required for PyLint, Anaconda does not add it like do with pep8 and PyFlakes libraries, if you want to use PyLint as your linter you have to donwload and install it yourself.
Anaconda does not use a subprocess to call the PyLint linter like Pylinter plugin does. We just import some files from pylint and run the linter from the jsonserver process capturing the system stdout file descriptor. That means anaconda will use your configured python interpreter (and environment) in order to lint your files with PyLint so it should be installed in your virtualenvironment if you are using virtualenv.
PyLint does not support lint buffers that are not saved yet in the file system so it can't lint files before you save it.
Anaconda uses E, W and V codes to maintain compatibility with PyFlakes and PEP8 linters so the PyLint mapping is as follows:
PyLint errors can be ignored using the setting parameter pylint_ignore .
When you use PyLint, PyFlakes and PEP8 are totally turned off.
Note: PyLint can be really annoying use it at your own risk
Error lines mark
You can control the way that anaconda mark the error lines in your files adjusting the setting anaconda_linter_mark_style
- If it's set to outline (default) anaconda will outline error lines
- If it's set to fill anconda will fill the lines
- If it's set to none anaconda will not draw anything on error lines
This program is distributed under the terms of the GNU GPL v3. See the LICENSE file for details.
Guide to solve common trobleshootings
Anaconda does not appear in the available packages list on Package Control
You have to update your package control version to the version 2.0 or better
I get errors in the console about "the file can't be open" in worker.py file
Your sublime text can't find the interpreter that you set in your configuration, by default, anaconda set this as python so it will get your configured Python interpreter in your PATH (if any)
Contributing with Anaconda
There are several ways to contribute with anaconda.
- By giving feedback about the plugin and how it works in your platform.
- By reporting bugs in the issue tracker
- By sharing your ideas with us
Did you found a bug and you know how to fix it? First of all, thank you very much. You just have to report the bug as a new issue, fork the repository, make your changes and send a new pull request.
So you thougth about a new killer feature to implement in Anaconda?. Great!. Open an issue tagged as "Feature" and we will discuss it with you.
Mac OS X machine donator
Do you have a Mac OS X box that you don't use anymore and its abandoned in a corner? Just send it to us, put yourself in contact with us and lets talk.
note: we need only one so this section will disappear in the future
возвышенный текст 2 пользователя
После завершения ввода нажмите Enter, и вы можете ждать долгое время. В это время вы можете пойти на чашку кофе и дождаться, пока он установится. Вы можете увидеть «Управление пакетами» на вкладке «Настройки», что означает, что установка прошла успешно.
Goto Python Definition
Jump to any file that define the Python object under the cursor
Нужно быть в np.
Просто подожди немного
Затем давайте поговорим о работе кода, как написать код в возвышенном и запустить его напрямую.
Я запускаю R в Subilme, Фактически, в основном используется плагин sublimeREPL. Если у вас есть этот плагин, перейдите прямо кНастройка среды в настройке-Пользователь
Anaconda works fine out of the box (always that there is a Python interpreter configured in your path and the binary is named python ) but if you want to get the max from it, you can configure multitude of options to tune it and adapt it to your needs.
To take a look at the common configuration of the Anaconda powerful IDE features, take a look at the Powerful IDE section, in this section we will speak about where and how to configure anaconda to use multiple virtual environments, create hook config files and other anaconda specific options that can make your life way easier.
Let’s start from the beginning.
Yes, it does. Anaconda supports virtual environments out of the box, but you have to tell it where to find the python binary of your virtual environment.
This can be done configuring the python_interpreter option in any of the several ways that anaconda allow you to fine tune your plugin installation.
You can place anaconda settings in three different places.
If you choose the first and second options, take into account that you are effectively configuring Anaconda globally so the plugin will behave in the way that you configure it for any Python file that you edit if there is no a specific project configuration file that hides and override your global configurations (more about this later).
To configure the plugin using the global or user anaconda settings file, just go to Preferences > Package Settings > Anaconda , there you will find two different entries, Settings-Default and Settings-User for options 1 and 2 respectively. Any option in those files have to be placed in the global scope.
note: Settings-Default should be pre-populated with all the available anaconda plugin options configured to it’s default behaviour.
note: We strongly recommend to use Project configurations always
Подключаемый модуль загрузки Sublime Text3 Anaconda
Когда многие люди научатся писать код, у них будут разные редакторы. Великие боги посоветовали мне использовать возвышенное, но я написал код в нем, без намека, боже мой, не сжигайте мне мозг. Я использую Anconda для изучения Python, но этот спайдер немного неудобен. Итак, сделаем это.
Сначала установите управление пакетами в возвышенном:
Выберите в представлении показать консоль, а затем откройте ссылку ниже
Войдите в управление пакетами в настройкахinstall package
Поскольку сам плагин не может знать путь, по которому установлен Python, вам необходимо вручную указать местоположение основной программы Python. ВыбратьPreferences-package Setting-Anaconda- Settings-Default 。
Выбрать Preferences-package Setting-Anaconda- Settings-UsersВариант, введите следующие данные json. Сохраните и перезапустите возвышенное
1 - это путь, по которому я установил анаконду, потому что я установил анаконду и установил питон. Таким образом, нет необходимости следовать онлайн-руководствам и использовать другие способы.
2 заключается в решении важной проблемы, а именно:
3 заключается в решении проблемы белых ящиков.
Затем sublime3 будет иметь функцию подсказки при написании кода Python.
Install using Git
As third option, you can just go to your SublimeText 3 packages directory and clone the repo directly from Github, in that way you can easily install updates just running git pull in the directory.
Auto Imports
Try to import the undefined word under the cursor
Environment hook files
There are high probabilities that the only configuration option that you ever change in your projects is just the python_interpreter and the extra_paths . If that is your case, maybe you want to use environment hook files instead of configure your projects directly.
Project and Python Interpreter Switching
If you change your configured python interpreter or you just switch your project, the plugin will detect it and reload a new completion/linting/IDE JsonServer killing the old one in a total transparent way so you don’t need to restart your Sublime Text 3.
note: is for some strange reason you don’t want that your anaconda plugin behave in this way, you can always change the configuration option auto_project_switch to false and anaconda will not auto switch the interpreter as described above.
warning: Windows users can experiment weird behaviour after a project or python interpreter switch due inconsistence in the WinSocket state, if this happens, Anaconda will complain and show an error window. The only solution if this happens is restart Sublime Text 3.
note: The plan is to port Tulip from Python 3.4 into anaconda to replace the anaconda’s custom asynchronous IOLoop.
This project is maintained by @damnwidget with the help of several contributors.
Anaconda is a plugin that turns your SublimeText 3 into a rich featured Python development stack that boost your productivity and helps you to ensure the quality and style of your code.
Out of the box
The plugin works out of the box with no configuration but we recommend to become familiar with the numerous anaconda's configuration options to fine tuning your installation to get all the power that Aanaconda can offer you.
By default, anaconda uses the python interpreter that is in your PATH environment variable, the most important configuration option is the python_interpreter option that allow the user to use a different python interpreter, for example, one that resides in a virtual environment:
Note: for detailed information about how to properly configure anaconda to get the maximum of it, follow the Configure Anaconda the Right Way section.
To use anaconda you need to have installed Sublime Text 3 first, you can download it from it's official website in case that you didn't already.
Manual installation
You can download a compressed packed version of anaconda from the link below and decompress it into your SublimeText 3 packages directory
- Linux: ~/.config/sublime-text-3/Packages
- OS X: ~/Library/Application Support/Subime Text 3/Packages
- Windows: %APPDATA%\\Sublime Text 3
Find Object Usages
Find where the object under the cursor is being used
McCabe Complexity Checker
Analyze your code with the Code Complexity Checker McCabe to detect overcomplex algorithms or functions
Disable Linting on File
Useful when you don't want to lint a file
Overriding details per project
Anaconda will always try to use any options that are found in the project file of the project that you are working on first. This is pretty useful as you can override and modify the behaviour of the plugin depending of your current environment.
For example, if you are working in an Open Source project that follows full PEP8 and strict coding standards, you can configure your anaconda linters in totally strict mode but relax them in other environments where such practices are (unfortunately) not being used.
To archive this desirable behaviour you can add whatever configuration option that you need in your project configuration file, including (and specially) the python_interpreter one.
To edit your project configuration file just go to Project > Edit Project . The options must be placed inside the settings dictionary
Anaconda has the ability to use whatever python interpreter that you can compile and use in your platform, this includes:
Python Interpreter | Python 2x | Python 3x |
---|---|---|
CPython | ||
PyPy | ||
Jython | N/A | |
Stackless |
Anaconda allows you to complete, linting, analyze and use all the anaconda features with whatever python interpreter that you want, that of course includes python interpreters residing in virtual environments
Imports Validation
Check if file imports are valid
Code Linting
Lint Python syntax errors and PEP8 violations
Installation
The easiest way to install anaconda is using Package Control for SublimeText 3, in case that you don't have installed Package Control already, just follow the installation guide in the Package Control website.
To install anaconda trough Package Control show the Command Palette (Tools -> Command Palette) and write install package
then write anaconda in the input window popup that just appeared (that is the SublimeText 3 Command Palette) and press enter
Virtualenv environment variables
If you are using a virtualenv for your python_interpreter and you start your Sublime Text 3 from the command line (to inherit environment variables on OS X and Linux) you can use the variable $VIRTUAL_ENV in your python_interpreter configuration option.
Example of global user configuration (Packages/User/Anaconda.sublime-settings):
Exaple of project configuration (~/projects/my_project/MyProject.sublime-project):
What is an environment hook file?
An environment hook file is a JSON file named .anaconda that resides in the root of your working directory or in any directory level up to drive root directory. If a valid hook file exists on that directory tree, it will be used instead of your project or general anaconda configuration. A valid .anaconda hook file is as in the example below.
note: take into account that only python_interpreter and extra_paths can be hooked, any other option will be ignored
Per Project Configuration
Anaconda run just fine out of the box (always that you have a valid python interpreter configured and in your PATH ) but it's also possible (and desirable) a finer per project configuration. You can configure anaconda in all the projects that you want.
To configure anaconda to behave differently in certain project you just have to edit the project configuration file
(Project -> Edit Project) and add any configuration that you need into the "settings" key:
Check the configuration documentation to get a much more extensive information
This project is maintained by @damnwidget with the help of several contributors.
Auto Format PEP8 Violations
Try to solve automatically PEP8 errors in the file
With performance in mind
The main goal of anaconda is to provide a high performance python development environment, this is why anaconda will never freeze your SublimeText 3 as everything in anaconda runs concurrent and asynchronous using an asynchronous client-server architecture.
Configuring the Python Interpreter
Anaconda will use your PATH configured python interpreter by default out of the box. To use another interpreter just change the python_interpreter configuration option globally or (more usually) in your project files as is shown in the examples below
Example of global user configuration (Packages/User/Anaconda.sublime-settings):
Exaple of project configuration (~/projects/my_project/MyProject.sublime-project):
Tests Runner
Run your project unit tests with the granularity that you need
три
- После установки Packages Contorl в sublime после открытия Preferences – Packages Control появится всплывающая консоль,Чтобы войти в установочный пакет,Подождав некоторое время, введите анаконду во всплывающем поле ввода и выберите его,Нажимаем Enter и ждем установки. После успешной установки вы можете увидеть анаконду в Preferences-Packages Settings. как показано на картинке
- Затем «Настройки» - «Настройки пакетов» - «Анаконда» - «Настройки - по умолчанию»,Нажмите ctrl + f, чтобы найти метку с именем "python_interpreter",Измените путь к вашему пути python.exe, python.exe - это путь, а не путь, по которому находится python.exe. Тогда вы можете с радостью использовать свое возвышенное, чтобы изучить свой питон.
- но. Некоторые функции Anaconda сейчас не используем, можно отключить. Нажмите Preferences – Packages Settings --anaconda – Settings-User, чтобы открыть, и введите следующую конфигурацию.
“suppress_word_completions”: true,
“suppress_explicit_completions”: true,
“complete_parameters”: false,
//“anaconda_linter_phantoms”: true,
“pyflakes_explicit_ignore”:
[
// “Redefined”,
“UnusedImport”
// “UndefinedName”,
// “UndefinedLocal”,
// “UnusedVariable,”,
// “UndefinedExport”,
// “DuplicateArgument”,
// “RedefinedWhileUnused”
],
“anaconda_linting_behaviour”: “save-only”,
“anaconda_linting”: false
>
среди них “anaconda_linting”: false Для него установлено значение False, потому что каждый раз при сохранении возвышенного кода код будет заключен в белую рамку.Я не очень привык к этому, поэтому я закрыл его.
Auto Completion
Python Code Autocompletion
Extra Paths
I know, you are used to add loads of extra paths to make your completions work in other plugins. In Anaconda, extra means just that extra , your Anaconda plugin will be able to lint, complete and analyze any package and module that your configured python interpreter is able to see.
That means that you should use this options only for real extra packages that are not in your site-packages (SublimeText python files in the sublime text installation directory for example). You can add as many extra paths as you need in a list separated by commas in both your global or project configuration files.
Example of global user configuration (Packages/User/Anaconda.sublime-settings):
Exaple of project configuration (~/projects/my_project/MyProject.sublime-project):
два
Загрузите sublime text3 из Tencent Computer Manager или Baidu и установите Package Control
(если вы уже установили, вы можете сразу увидеть третий шаг)
- Это официальный сайт Sublime, нажмите, чтобы загрузить понравившуюся версиюsublime text
Поскольку источник программного обеспечения sublime является иностранным, загрузка выполняется очень медленно. Рекомендуется найти и установить его на Baidu. Намного быстрее, чем на официальном сайте. - После установки sublime. Откройте sublime и используйте ctrl + `(~)
Show Documentation
Open a bottom pannel with documentation about the class, method or function where your cursor is
Читайте также: