PyChram autocomplete for import library

Answered

 if I write the code below in python file(.py).

import numpy as np
import pandas as pd

test_df = pd.read_csv('testdata/testdata.csv')

and if i type 'pd.' or 'test_df.' and press ctrl+space button, anything show up.

I could I fix it?

 

58 comments
Comment actions Permalink

I provided everything that’s needed above. As an ALL TOOLS Subscriber, it’s really frustrating when a commercial tool doesn’t do what even the most basic FREE IDE’s do, and the developer just pushes it off as a “feature request” instead of a bug.

This is not the first time Jet Brains has tried to redirect what is clearly a bug as a feature request. Makes me wonder why I continue the subscription.

4
Comment actions Permalink

This happens to me with other libraries that aren't pandas. Further more, PY-28459 seems to be more of a feature request, while this issue, as indicated by several reports from other users over the last few months, is not a feature request, but rather a request to fix a bug, that I would consider pretty major, given that code completion is something pretty fundamental to this tool.

Andrey, I wouldn't want this to be treated as a feature request, as we're not asking for a feature, we're asking for a basic component of the IDE to be fixed.

3
Comment actions Permalink

"This is not the first time Jet Brains has tried to redirect what is clearly a bug as a feature request. Makes me wonder why I continue the subscription."  So true, after several years subscribing, I have decided I will no longer continue. JetBrains seems to prefer function bloat over fixing what should have worked in the first place. MS Studio Code, here I come...

3
Comment actions Permalink

The way to fix this issue is to go to File-->Settings-->Project Structure and select the folder with the import files and mark them as sources. At least it worked for me..

2
Comment actions Permalink

Have you tried to run "File | Invalidate caches"?

1
Comment actions Permalink

Worked for me, just do as follow:

  1. Create empty project in pycharm.
  2. Add your files
  3. Add your import it will work

what made my case not working, is default popup of pycharm shows after installation, then i choose create project

i created the file after that, it was not working.

But when you do file new project, it will install bunch of things and will look as below

The case that not working looked like this

 

1
Comment actions Permalink

Yeah. I check it already.

In the python code script isn't work

But in the console mode, it works

0
Comment actions Permalink

There is a yellow warning that no interpreter is configured. Add interpreter  in "Settings | Project | project Interpreter".

0
Comment actions Permalink

I added it. 

However, autocomplete still not works.

 

0
Comment actions Permalink

i am also having same trouble for other modules.

0
Comment actions Permalink

Hi Csai,

What kind of trouble? Screenshots are welcome.

0
Comment actions Permalink

Auto complete suggestion are coming on the console but not in the editor as mentioned by cjse3178

0
Comment actions Permalink

Do you use conda?

Try File | Invalidate Caches/Restart... to make PyCharm reindex your interpreter.

0
Comment actions Permalink

No i do not use conda
And i also tried File | Invalidate Caches/Restart but it didn't work

0
Comment actions Permalink

Please attach a screenshot of your Project Interpreter and another one which shows the problem in editor.

0
Comment actions Permalink

its not working in the editor.

 

only working in the python console.

0
Comment actions Permalink

how can i fix it..??

0
Comment actions Permalink

Which package is it specifically? Would be great to see the whole script.

Also, what about Project Interpreter? Could you attach a screenshot of it?

0
Comment actions Permalink

I believe this is due to the fact that it is imported dynamically and PyCharm doesn't introspect it that deep while in Python Console the line is already executed and dynamic import is already performed.

Not sure if we can support such case, but feel free to submit a feature request about it to our issue tracker using the link https://youtrack.jetbrains.com/issues/PY

0
Comment actions Permalink

HI,

I am Using Pycharm professional, and I am facing same problem. I do appreciate your help and support

Regards,

Mohamed Alshishani

0
Comment actions Permalink

I'm having the exact same issue with no code completion suggestions for unittest.

Have tried File | Invalidate Caches/Restart as well

0
Comment actions Permalink

I have the same problem, even though I'm able to run my code locally with the remote interpreter...any ideas?

0
Comment actions Permalink

Some suggestions:

1. Try File > Invalidate caches / restart

2. Make sure power save mode is off

3. Try to delete / recreate the interpreter. If using SSH interpreter, delete ~/.pycharm_helpers from remote host as well.

0
Comment actions Permalink

I'm having a very similar issue. Pandas was autocompleting basic things like pandas.DataFrame.columns, pandas.DataFrame.index, now it's not finding any of those but some internal private methods.

I've followed the steps, Andrey as provided. No improvement. Not sure how to fix.

0
Comment actions Permalink

Jim

Please provide a working snippet of the code where completion isn't working.

0
Comment actions Permalink

Andrey Resler

Here's very simple code, using a fresh Conda python 3.75 environment with only pandas and numpy installed:

import pandas as pd
import numpy as np


class Car(object):
wheels = 4
doors = 2
engine = "4 cyl ICE"


if __name__ == "__main__":
df1 = pd.DataFrame(np.random.randn(5,3), columns=['hickory', 'dickory', 'dock'], index=['alpha', 'beta', 'charlie', 'delta', 'edward'])
print(df1.index)
print(df1.columns)

c1 = Car()
print(c1.wheels)


See screen grabs of trying to autocomplete. Basically, none of the properties or fields are getting proposed in the Autocomplete.

Here `pandas.DataFrame.index` is not being proposed...

Here `pandas.DataFrame.columns` isn't being proposed.

However a non-imported class works:

This all used to work only a few updates back... I'm not sure what changed, but it's kind of crappy when VS Code can do this for "free" and my paid JetBrains tool cannot.

0
Comment actions Permalink

David,

Could you please submit a bug report to https://youtrack.jetbrains.com/issues . and provide:

- Code sample and steps to reproduce the issue

- Logs: https://intellij-support.jetbrains.com/hc/en-us/articles/207241085-Locating-IDE-log-files

0
Comment actions Permalink

Jim,

The snippet you provided is about pandas dataframes, right? As I mentioned, there's a known issue for that: https://youtrack.jetbrains.com/issue/PY-28459

By the way, this issue is registered as bug, not feature request. And yes, I agree it's pretty essential and should be fixed.

UPD: I just noticed it was changed from feature request to bug by our QA engineer, so kudos to him.

 

Then, David mentioned that he has similar issues with other packages, without mentioning which packages exactly (maybe those issues are already known). Actually, we have many unique package-specific issues in our bug tracker. What's more, investigating complex issues like that in forum thread is counter-productive, so I believe it's much more effective to submit an issue. If it's known, we'll mark it as duplicate, if it's a new issue - we'll investigate and assign priority.

I didn't mean to cause any frustration.

0

Please sign in to leave a comment.