7

I have no idea what I could have done but Pycharm now decides to claim that it doesn't know things like TaggedDocument or Doc2Vec although it worked an hour ago.

enter image description here

This is my project structure:

enter image description here

I can't remember doing anything that could have cause this so please tell me how I could fix this.

The thing I don't get it that under "External Libraries in the Project Explorer I can actually see that gensim.models.doc2vec is actually present. So why does PyCharm still complain here?


enter image description here


Update

I noticed the following: In the package gensim.models I see that the file doc2vec.py is not labeled as a Python file! Please note on the right side that there is also no syntax highlighting! The strange thing is that all other files in that directory are actually recognized correctly!

enter image description here

These are the file permissions under /usr/local/lib/python2.7/dist-packages/gensim/models

drwxr-sr-x 3 root staff   4096 Oct 23  2015 .
drwxr-sr-x 9 root staff   4096 Oct 23  2015 ..
-rw-r--r-- 1 root staff 570651 Oct 23  2015 doc2vec_inner.c
-rw-r--r-- 1 root staff  26872 Oct 23  2015 doc2vec_inner.pyx
-rwxr-xr-x 1 root staff 473658 Oct 23  2015 doc2vec_inner.so
-rw-r--r-- 1 root staff  37304 Oct 23  2015 doc2vec.py
-rw-r--r-- 1 root staff  35822 Oct 23  2015 doc2vec.pyc
-rw-r--r-- 1 root staff  23000 Oct 23  2015 hdpmodel.py
-rw-r--r-- 1 root staff  21250 Oct 23  2015 hdpmodel.pyc
-rw-r--r-- 1 root staff   1920 Oct 23  2015 __init__.py
-rw-r--r-- 1 root staff   2697 Oct 23  2015 __init__.pyc
-rw-r--r-- 1 root staff   6724 Oct 23  2015 lda_dispatcher.py
-rw-r--r-- 1 root staff   7451 Oct 23  2015 lda_dispatcher.pyc
-rw-r--r-- 1 root staff  37778 Oct 23  2015 ldamodel.py
-rw-r--r-- 1 root staff  32106 Oct 23  2015 ldamodel.pyc
-rw-r--r-- 1 root staff  12478 Oct 23  2015 ldamulticore.py
-rw-r--r-- 1 root staff  11924 Oct 23  2015 ldamulticore.pyc
-rw-r--r-- 1 root staff   4079 Oct 23  2015 lda_worker.py
-rw-r--r-- 1 root staff   5067 Oct 23  2015 lda_worker.pyc
-rw-r--r-- 1 root staff   4239 Oct 23  2015 logentropy_model.py
-rw-r--r-- 1 root staff   4452 Oct 23  2015 logentropy_model.pyc
-rw-r--r-- 1 root staff   7100 Oct 23  2015 lsi_dispatcher.py
-rw-r--r-- 1 root staff   7518 Oct 23  2015 lsi_dispatcher.pyc
-rw-r--r-- 1 root staff  34968 Oct 23  2015 lsimodel.py
-rw-r--r-- 1 root staff  27309 Oct 23  2015 lsimodel.pyc
-rw-r--r-- 1 root staff   3793 Oct 23  2015 lsi_worker.py
-rw-r--r-- 1 root staff   4848 Oct 23  2015 lsi_worker.pyc
-rw-r--r-- 1 root staff  10461 Oct 23  2015 phrases.py
-rw-r--r-- 1 root staff   9505 Oct 23  2015 phrases.pyc
-rw-r--r-- 1 root staff   3734 Oct 23  2015 rpmodel.py
-rw-r--r-- 1 root staff   4002 Oct 23  2015 rpmodel.pyc
-rw-r--r-- 1 root staff   6372 Oct 23  2015 tfidfmodel.py
-rw-r--r-- 1 root staff   6100 Oct 23  2015 tfidfmodel.pyc
-rw-r--r-- 1 root staff    310 Oct 23  2015 voidptr.h
-rw-r--r-- 1 root staff 517311 Oct 23  2015 word2vec_inner.c
-rwxr-xr-x 1 root staff  22906 Oct 23  2015 word2vec_inner.pyx
-rwxr-xr-x 1 root staff 357937 Oct 23  2015 word2vec_inner.so
-rw-r--r-- 1 root staff  72866 Oct 23  2015 word2vec.py
-rw-r--r-- 1 root staff  62243 Oct 23  2015 word2vec.pyc
drwxr-sr-x 2 root staff   4096 Oct 23  2015 wrappers

and here is the entire content of my doc2vec.py.

Community
  • 1
  • 1
Stefan Falk
  • 23,898
  • 50
  • 191
  • 378
  • are you using the correct python interpreter maybe you are using 2.7.x and not 3.x or the other way around? – Donat Pants Apr 24 '16 at 15:16
  • Under `Settings` of my project it says I am using `/user/bin/python2.7`. – Stefan Falk Apr 24 '16 at 15:20
  • shouldn't you be importing from wordvectors.models.doc2vec and not gensim.models.doc2vec? or even just from models.doc2vec – Donat Pants Apr 24 '16 at 15:21
  • If I **Ctrl + L-Mouse** `doc2vec` in `gensim.modls.dov2vec` it actually opens the file but it doesn't seem to interpret it as Python file since there is no syntax highlighting. – Stefan Falk Apr 24 '16 at 15:22
  • well to know what is wrong i would have to see the models pack and the source of Doc2Vec to see if it really has the TaggedDocument, Doc2Vec classes/functions in it – Donat Pants Apr 24 '16 at 15:24
  • @DonatPants No, in `models/` there is just a large CSV file. I want to use `gensim`. Like mentioned above this worked just fine an hour ago but all of a sudden it allies with all the other **** that is not working at the moment to make this an even greater hell than what it already is .. – Stefan Falk Apr 24 '16 at 15:24
  • IMHO adding the project's `.idea` dir to the version control system is a good way to figure out what causes unexpected PyCharm behaviour changes and often even restore the expected behaviour :) – Dan Cornilescu Apr 24 '16 at 19:27
  • http://stackoverflow.com/questions/33980313/how-to-put-intellij-pycharm-settings-under-version-control – Dan Cornilescu Apr 24 '16 at 19:36
  • Do you have gensim in settings -> Your project -> Project Interpreter Package list? – valex May 16 '16 at 14:21
  • @valex Yes it it (I added a screenshot) – Stefan Falk May 16 '16 at 14:52
  • Have you tried to uninstall the `gensim` package and install again? Thanks. – alecxe May 17 '16 at 02:32
  • @alecxe Yes, I even switched between the community and the education version. It's the same in both. The script is running but PyCharm keeps telling me that it does not find those classes even though it finds the files .. – Stefan Falk May 17 '16 at 10:33
  • Did you make sure that every directory that is a module have the \_\_init\_\_.py file? – Gabriel Muj May 20 '16 at 07:33
  • 2
    Try [cleaning the system caches](https://www.jetbrains.com/help/pycharm/2016.1/cleaning-system-cache.html): `PyCharm > File > Invalidate Caches / Restart ... > [Invalidate and Restart]` – Darius May 20 '16 at 12:36
  • @DariusM. Unfortunately this did not help either.. I am not getting this.. especially because the module is getting indexed and I can actually jump into the file .. – Stefan Falk May 20 '16 at 12:53
  • Are you actually getting errors or just the red underline? – Padraic Cunningham May 20 '16 at 23:03
  • @PadraicCunningham Only the red underlines and only for the gensim packages it seems .. – Stefan Falk May 22 '16 at 14:17
  • To me, this happens from time to time. Either invalidation of cache like above, or a restart will usually fix the problem. Otherwise, try to reinstall python. You should really look into running virtual env, since it's easier to rebuild everything if something fails. – OakNinja May 22 '16 at 21:26
  • @DonatPants Please see my update! – Stefan Falk May 23 '16 at 06:51
  • @DanCornilescu I updated my question - I found that `doc2vec.py` is for some reason not detected or interpreted as Python file O_o – Stefan Falk May 23 '16 at 06:52
  • @Darius Please see the updated question! – Stefan Falk May 23 '16 at 06:53
  • @displayname the only thing as I see it that could be the problem is that there is no `taggedDocument` or `Doc2Vec` inside `gensim.models.doc2vec`. would you mind showing the code inside that file? – Donat Pants May 23 '16 at 10:28

2 Answers2

1

Please check that you didn't accidently removed parts of the code from doc2vec.py file because it's strange that pycharm can give a direct path for this file but can't read it. Another thing that can happen but will be totally weird is things about permissions, maybe you've changed permissions in this folder and now pycharm doesn't have the permissions to read this file?

Rotem Vil
  • 224
  • 1
  • 8
  • I checked.. the class `Doc2Vec` is present in my `gensim.models.doc2vec`. I didn't modify any of these files. I am not getting this. No other library has this problem. Whether if it's `numpy`, `random` or `os` .. – Stefan Falk May 23 '16 at 06:47
  • Could you please upload the content of gensim.models.doc2vec? And again, I'm guessing you're on based unix OS (interpreter /usr/bin/python) so please do compare file permissions against other .py files in the same folder. – Rotem Vil May 23 '16 at 07:58
  • Another thing, please open settings (ctrl+alt+s), type in search bar for "file types", check that in the bottom text box there isn't a regex that matches your file and just for some weird case - look on python files to see if .py is registered as a registered pattern. – Rotem Vil May 23 '16 at 08:07
  • Tried all that. I checked file permissions (see updated question) and I uploaded the content of my doc2vec.py - I just don't get this. doc2vec.py is still the only file that does not get syntax highlighted. It's displayed as a textfile .. – Stefan Falk May 23 '16 at 11:06
  • Great thank you for all the info. My last guess is to try to change the name of the file by using refactor (Shift+F6) to doc2vec.txt and then again change the name of the file to doc2vec.py - please update me :) thanks! – Rotem Vil May 23 '16 at 11:10
  • Omg that was it! It somehow got under "Text" in "File Types" - I have no idea how but it seems I somehow messed up my config somewhere between the educational version and the community version! Thank you very much for your help - such a stupid mistake but at least it works finally! – Stefan Falk May 23 '16 at 11:12
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/112674/discussion-between-rotem-vil-and-displayname). – Rotem Vil May 23 '16 at 11:18
0

Last chance, try by enabling the following (source):

enter image description here

Community
  • 1
  • 1
Darius
  • 10,762
  • 2
  • 29
  • 50