python-rope / ropevim

vim mode that uses rope library to provide features like python refactorings and code-assists
GNU General Public License v2.0
245 stars 34 forks source link

AttributeError: 'NoneType' object has no attribute 'pycore' #36

Closed NicolasWebDev closed 9 years ago

NicolasWebDev commented 9 years ago

On an Ubuntu 12.04, with Vim 7.4, rope 0.10.2, ropemode 0.2 and ropevim 0.5.0

When I try to create a new project (using the :RopeRename method), I always get the error AttributeError: 'NoneType' object has no attribute 'pycore'

I have tried different ways of installing ropevim. The first one was decompressing it in .vim/bundle, and running sudo python setup.py install.

I then tried deleting the files it had installed, and installing it from pip instead, along with modifying the PYTHONPATH.

But invariably I get the same error.

For more info, if I issue a

:python import sys; print(sys.path)

, I get the following: ['/usr/lib/pymodules/python2.7', '/usr/lib/python2.7/dist-packages/PIL', '/usr/local/lib/python2.7/dist-packages/aeroolib-1.2.0-py2.7.egg', '/usr/local/lib/python2.7/dist-pa ckages/Genshi-0.7-py2.7-linux-x86_64.egg', '/usr/local/lib/python2.7/dist-packages/SimpleGUITk-1.1.3-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/clonedigger-1.1.0-py 2.7.egg', '/usr/local/lib/python2.7/dist-packages/sphinx_patchqueue-0.4.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/mercurial-3.1.2-py2.7-linux-x86_64.egg', '/usr/ local/lib/python2.7/dist-packages/Sphinx-1.3b1-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/snowballstemmer-1.2.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/ docutils-0.12-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/six-1.8.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages/pyrg-0.2.6-py2.7.egg', '/usr/local/lib/python 2.7/dist-packages/ropevim-0.5.0-py2.7.egg', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-linux2', '/usr/lib/python2.7/lib-tk', '/ usr/lib/python2.7/lib-old', '/usr/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages', '/usr/lib/python2.7/dist-packages /gst-0.10', '/usr/lib/python2.7/dist-packages/gtk-2.0', '/usr/lib/python2.7/dist-packages/wx-2.6-gtk2-unicode', '_vim_path_']

I also compiled vim, so if it may be the error I put also the result of vim --version: VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Feb 7 2015 09:37:20) Included patches: 1-602 Compiled by nicolas@nicolas-envydv7 Huge version without GUI. Features included (+) or not (-): +acl +farsi +mouse_netterm +syntax +arabic +file_in_path +mouse_sgr +tag_binary +autocmd +find_in_path -mouse_sysmouse +tag_old_static -balloon_eval +float +mouse_urxvt -tag_any_white -browse +folding +mouse_xterm -tcl ++builtin_terms -footer +multi_byte +terminfo +byte_offset +fork() +multi_lang +termresponse +cindent +gettext -mzscheme +textobjects +clientserver -hangul_input +netbeans_intg +title +clipboard +iconv +path_extra -toolbar +cmdline_compl +insert_expand -perl +user_commands +cmdline_hist +jumplist +persistent_undo +vertsplit +cmdline_info +keymap +postscript +virtualedit +comments +langmap +printer +visual +conceal +libcall +profile +visualextra +cryptv +linebreak +python +viminfo +cscope +lispindent -python3 +vreplace +cursorbind +listcmds +quickfix +wildignore +cursorshape +localmap +reltime +wildmenu +dialog_con -lua +rightleft +windows +diff +menu -ruby +writebackup +digraphs +mksession +scrollbind +X11 -dnd +modify_fname +signs +xfontset -ebcdic +mouse +smartindent -xim +emacs_tags -mouseshape -sniff +xsmp_interact +eval +mouse_dec +startuptime +xterm_clipboard +ex_extra -mouse_gpm +statusline -xterm_save +extra_search -mouse_jsbterm -sun_workshop -xpm system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/local/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -L/usr/local/lib -Wl,--as-needed -o vim -lSM -lICE -lXt -lX11 -lXdmcp -lSM -lICE -lm -ltinfo -lnsl -ldl -L/usr/lib/python2.7/config/ -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions

NicolasWebDev commented 9 years ago

I have also tried on an Ubuntu 14.04, with the ubuntu vim build, installing from the setup.py, or installing from pip directly and adding the .vim/bundle/ropevim/ directory to the PYTHONPATH, still no luck.

Other rope commands give me different errors.

NicolasWebDev commented 9 years ago

Well, after so many days, I still haven't found the solution, and nobody on the web seemed to be able to help me.

mcepl commented 9 years ago

When I try to create a new project (using the :RopeRename method), I always get the error AttributeError: 'NoneType' object has no attribute 'pycore'

Complete traceback would be more helpful for investigating this issue.

NicolasWebDev commented 9 years ago

Sorry for forgetting to include all of it. Actually none of the :Rope commands work, I would guess because of a bad installation somewhere.

Here you have the error using RopeRename:

Rope project root folder: .0. yes
1. no
Project not exists in ., create one?Project creation aborted
Error detected while processing function RopeAnalyzeModule:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/d
ecorators.py", line 53, in newfunc
    return func(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/i
nterface.py", line 396, in analyze_module
    self.project.pycore.analyze_module(self.resource)
AttributeError: 'NoneType' object has no attribute 'pycore'

Here the error using RopeChangeSignature:

Rope project root folder: .0. yes
1. no
Project not exists in ., create one?Project creation aborted
Error detected while processing function RopeChangeSignature:
line    1:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/decorators.py", line 53, in newfunc
    return func(*args, **kwds)
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/interface.py", line 52, in do_refactor
    refactoring(self, self.env).show(initial_asking=initial_asking)
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/refactor.py", line 32, in show
    self._create_refactoring()
  File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/refactor.py", line 367, in _create_refactoring
    self.project, self.resource, self.offset)
  File "/usr/local/lib/python2.7/dist-packages/rope-0.10.2-py2.7.egg/rope/refactor/change_signature.py", line 13, in __init__
    self.pycore = project.pycore
AttributeError: 'NoneType' object has no attribute 'pycore'

Thanks for your help.

mcepl commented 9 years ago

What happens when you clone the repo and in the master branch run

python setup.py test

(expecting your python is python2; rope doesn't support py3k yet)

NicolasWebDev commented 9 years ago

Not much actually.

$ python --version
Python 2.7.3
$ python setup.py test
running test
mcepl commented 9 years ago

Sorry, silly me ... of course, tests which matter are in rope, not ropevim.

NicolasWebDev commented 9 years ago

Indeed now there is more output ^^. Here is the result:

----------------------------------------------------------------------
Ran 1555 tests in 5.449s

OK
aligrudi commented 9 years ago

Sathors notifications@github.com wrote:

Sorry for forgetting to include all of it. Actually none of the :Rope commands work, I would guess because of a bad installation somewhere.

Here you have the error using RopeRename:

Rope project root folder: .0. yes
1. no
Project not exists in ., create one?Project creation aborted

Could this typo be fixed; it should be "Project does not exist" of course (open_project() method in ropemode/interface.py).

About the problem, do ropevim properly show the dialog for the second question ("create one?") and, if so, doesn't answering yes work?

Error detected while processing function RopeAnalyzeModule: line 1: Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/d ecorators.py", line 53, in newfunc return func(_args, *_kwds) File "/usr/local/lib/python2.7/dist-packages/ropemode-0.2-py2.7.egg/ropemode/i nterface.py", line 396, in analyze_module self.project.pycore.analyze_module(self.resource) AttributeError: 'NoneType' object has no attribute 'pycore'

Maybe we should raise an exception in open_project() instead of printing "Project creation aborted" so that the pending command terminates?

Ali
NicolasWebDev commented 9 years ago

Wowowow...

Well, actually, answering yes did the trick... I was pretty sure that the default was yes, and now that I am looking, it does say what to input, but in a quite unreadable/unformatted way.

And I think also that answering nothing (which is the default), should return something else than an attribute error, that's why I would never have thought it was supposed to be a sane behavior.

Thanks very much for the help, and sorry for the fuss, but I think it will really gain from being better formatted as well (and the different typos fixed by the way).

Thanks for the great work!

yggdr commented 8 years ago

Erm... Might this be fixed, please? It's still rather annoying and time consuming. Thanks

mcepl commented 8 years ago

Fixed what? The reporter here didn’t create the project root folder (see Project not exists in ., create one?Project creation aborted in his report) and so Rope didn't work. That isn't a bug, IMHO.

yggdr commented 8 years ago

What I meant was the fact that you had to explicitly type "yes" at the prompt in question. Everything else fails horribly, even "Yes". This shouldn't happen. Either give a message like "please type 'yes' to create project", or just accept empty input as implied yes, like one would assume. Not just spout some cryptic error message that sets unsuspecting users up for a wild goose chase.

Yes, I realise that "Project creation aborted" is technically in there, but its formatting plus the fact that big red error messages tend to draw the eyes should indicate that this might not be the best handling of this situation. So if someone could change this user interaction, it would save some poor sob quite a bit of hassle in the future, I'd wager. Thanks again.

mcepl commented 8 years ago

Please, file a separate bug for better UI.