10

I'm using pycharm IDE, and several libraries such as scikit-learn and pandas. For some reason, if I create a new python file and do:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plot
pd.   #no auto complete here

right after i type pd. auto complete doesn't seem to work. I'm getting nothing. However, if i run a python console within PyCharm, and do similar thing above, the console would pop up an autocomplete window showing all the members of pd..

how do i get autocomplete to work on the main python file?

user2773013
  • 3,102
  • 8
  • 38
  • 58
  • Is Runtime-Type-Detection enabled? (`Preferences->Python Debugger->"Collect run-time types information for code insight"`) – Leistungsabfall Sep 25 '14 at 16:14
  • i think it wasn't done "indexing" or whatever. It seems to work fine now. I should've been more patient. – user2773013 Sep 25 '14 at 16:21
  • @Leistungsabfall The auto completes is not working in IDE but it is working in PyCharm's Python Console. I did restart my PyCharm and freshly opened my folder as new project. Nothing works!! I don't know how it suddenly breaks. – Karthick Mar 13 '15 at 09:39
  • @Leistungsabfall: I enabled that option but did not get autocompletion for scikitlearn and other 3rd party packages that I installed. Do you think I need something else? Thanks! – arefin May 01 '15 at 11:01
  • 4
    Is this question resolved? I fall in the same swamp now... – Blaszard Feb 16 '16 at 12:04
  • Possible duplicate of [How do I import modules in pycharm?](https://stackoverflow.com/questions/19885821/how-do-i-import-modules-in-pycharm) – Pedram May 25 '19 at 06:00

2 Answers2

3

I used to have this same problem. This was only happening for me in Linux. (I am using python 2.7)

I have since been able to fix it, I think what did it was defining the correct interpreter not only in the running/debugging configuration, but also in the defaults of the project (check File-->settings-->Project Interpreter and File-->default settings-->Project Interpreter)

I have now moved to the next problem, which is that auto-complete works for Python Console and File editing, but weirdly enough does not work for Debugging!...

ntg
  • 12,950
  • 7
  • 74
  • 95
  • Ah that's correct. I had a mixed project with python3 and python2 source code. And I assumed it would use auto completion of the currently configured run profile. Thx – KoKlA Aug 27 '19 at 21:41
0

Never name project script numpy.py identical to package name numpy

This is just one possibility that causes autocompletion to fail for only one package: If you by accident name a project script identical to a package name, e.g. creating a python script numpy.py in your project and try to import numpy then pycharm will refer to your project script in autocompletion instead of to the package numpy.

This normally rather happens when using less common packages with more unknown names or e.g. a script name like code.py which will break autocompletion due to the package code.

drstoop
  • 324
  • 3
  • 6