SublimeRope
SublimeRope copied to clipboard
Autocompetition not working on Windows 7/8
Hi,
I was pretty excited to try out Sublime Rope, but somehow it does not work on Windows at all. I am guessing this is because Sublime Rope thinks that the Python shipped with SublimeText is the system Python, but introspection/auto-competition don't work at all.
Someone else ran into a similar issue here:
http://stackoverflow.com/questions/13609519/sublimerope-autocompletions-not-working-on-windows
I get the exact same errors.
It's working pretty well for the fellas that uses W7 in my job.
I suggest to take a look at http://sublimerope.readthedocs.org/en/latest/cache_mechanisms.html#cache-mechanisms in the SublimeRope documentation and make sure is all ok.
For example, some ppl forget to add a the autoimport modules to the settings object in the project file:
"settings": { "rope_autoimport_modules": [ "twisted.", "numpy.", "libsaas.*", ... ] }
I might be forgetting something - but in this case I am not working within a project, I am just editing a single python file outside of a project. Functions that are locally defined have a functional introspection, but every other function/module doesn't seem to have introspection available.
Attempting to use 'regenerate global cache' gives the same error as described by the stackoverflow user.
Edit: I tried making a project, and editing both the local project settings as well as the global settings, and autocompletion is still failing.
@FedericoV in this case, you should add the modules you want to cache as global cache in the SublimeRope.sublime-settings file directly
Did you add it in your SublimeRope.sublime-settings file? Can you paste your SublimeRope.sublime-settings configuration?
Sure, here is the SublimeRope.sublime-settings file:
{
"suppress_word_completions": false,
"suppress_explicit_completions": false,
"use_simple_completion": false,
"add_parameter_snippet": true,
"use_autoimport_improvements": true,
// non-trivial / nested modules have to be added with ".", e.g. "numpy."
// You can specify "autoimport_modules" in your project settings as project
// specific opions. Navigate to Project->Edit Project and add your modules
// there the settings
section. If settings section doesn's exists just
// create it:
"settings":
{
"rope_autoimport_modules":
[
"scipy.",
"numpy.",
"pandas."
]
},
"autoimport_modules": ["numpy.", "scipy.", "pandas."],
"pyflakes_linting": true,
"complete_as_you_type": true,
"case_sensitive_completion": true
}
And, as an addendum, here is my local project file:
{ "folders": [ { "path": "/D/Systems_Biology/Network_Analysis/" } ], "settings": { "rope_autoimport_modules": [ "scipy.", "numpy.", "pandas.*" ] } }
By the way - adding these lines at least makes it so that if I ask to regenerate the global/local cache I no longer get an error box - however, it doesn't appear to do anything.
You should comment out all the "settings" object in your SublimeRope settings file because that doesn't work at all iin that file, only in projects.
The Module Global Cache takes a bit to regenerate itself and sometimes a ST 2 restart can give a help too.
I restarted and commented out the settings file, but introspection still seems to be broken, even after a file is imported. I also added a non-existent module to the autoimport settings file, and that didn't seem to have any effect.
I did a very ugly hack, and added a print sys.path in sublime_rope.py, and this is the output:
['C:\Users\Federico - Windows\AppData\Roaming\Sublime Text 2\Packages\SublimeRope', 'python26.zip', '.', u'C:\Users\FEDERI~1\AppData\Roaming\SUBLIM~1\Packages\PACKAG~1\lib\all', u'C:\Users\FEDERI~1\AppData\Roaming\SUBLIM~1\Packages\PACKAG~1\lib\windows']
Clearly this suggests that sublime_rope is using the wrong python.
I fixed it by adding:
sys.path.insert(0, r"C:\Python27\Lib\site-packages")
In sublime_rope.py - which seemed to totally fix the problem and now introspection/code completion works.
Obviously this is inelegant, but somehow it works. Note - completion still only works for modules that are either local to the project or that I specified in the cache, but not modules that are imported in the file and aren't mentioned in the project/global cache. I'm not sure if this is the expected behaviour.
@DamnWidget mine still doesn't work. My SublimeRope.sublime-settings files looks like this:
{
"suppress_word_completions": false,
"suppress_explicit_completions": false,
"use_simple_completion": true,
"add_parameter_snippet": true,
"use_autoimport_improvements": true,
// non-trivial / nested modules have to be added with ".", e.g. "numpy."
// You can specify "autoimport_modules" in your project settings as project
// specific opions. Navigate to Project->Edit Project and add your modules
// there the settings
section. If settings section doesn's exists just
// create it:
// "settings":
// {
// "rope_autoimport_modules":
// [
// "twisted.",
// "numpy.",
// "libsaas.*",
// ...
// ]
// },
"autoimport_modules": ["math.*"],
"pyflakes_linting": true,
"complete_as_you_type": true,
"case_sensitive_completion": true,
// If true, class properties/methods will be included in the 'jump-to-global' list,
// in addition to the module-level objects (similar to Eclipse's globals browser).
// Requires a re-gen of the cache if this setting is changed.
// Note: slightly shower since there are more objects to index
"include_classmethods_in_globals": true
}
I suggest you to move the autoimport_modules from your global SublimeRope settings file to your project settings file nd then remove globalnames and objectdb files from .ropeproject directory (in your project directory) and rebuild the project and global caches again.
Why will this work? There must be a better way b/c this will require me to repeat this procedure ever time I start a new project. There are some modules I would want to automatically import b/c I use them frequently in different projects (eg. math.sin()).
Also, is the project settings file the config.py?
I've recently run into a similar issue on Linux as well as Windows, and the problem is exactly the same. SublimeRope insists on using the Python it ships with, and not the Python I want. I have set up a custom build environment, so that SublimeText knows which Python to use when running my scripts, but that has no effect on SublimeRope.
Yes, SublimeRope always uses the Python built into Sublime Text, it's part of its architecture and is not going to change. Consider testing the rewrite I started for ST3 (if you can use that), which uses a client-server model. It starts a Python of your choice (e.g. from your venv) acting as a completion-server, while the Python built into ST3 just messages it, and updates the GUI.
https://github.com/JulianEberius/SublimePythonIDE
Another option would be to backport SublimePythonIDE to ST2... it's really a lot easier to use and much faster. It does not yet have all the features of SublimeRope (no refactorings), but all the basic ones are there.
I'll give it a spin - how are you meant to install it?
I started ST3, and installed the package manager, but your plug in does not show up on the list, and cloning the git repo in the packages directory doesn't seem to do the trick. I also tried copying the git repo in the installed packages directory, and that also didn't do anything.
On Tue, May 14, 2013 at 12:21 PM, Julian Eberius [email protected]:
Another option would be to backport SublimePythonIDE to ST2... it's really a lot easier to use and much faster. It does not yet have all the features of SublimeRope (no refactorings), but all the basic ones are there.
— Reply to this email directly or view it on GitHubhttps://github.com/JulianEberius/SublimeRope/issues/54#issuecomment-17867886 .