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

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

I am having the exact same issues outlined above. When will this be fixed??

0
Comment actions Permalink

Hello, please check this https://intellij-support.jetbrains.com/hc/en-us/community/posts/360000142284/comments/360000383760 

If it is not your case, please attach a simplified code and screenshots presenting the issue. 

 

Thank you. 

0
Comment actions Permalink

Same Problem here. Switched to Pycharm Professional 2020.1.3 and now facing this issue in exact same way as was described by others in this thread. All workarounds described in this thread do not work for me (invalidate cache, reassign interpreter, etc.) Autocompletion works in the console but does not work in the editor.

Is there a time line to fix it?

Thank you!

0
Comment actions Permalink

I am facing the same problem, I am getting okay in the python console. but I am not getting proper autosuggestion or autocompletion in the code editor. I tried to Try File > Invalidate caches / restart. I am not getting autosuggestion in the code editor.

for example,autocomplete works pandas

df.iloc[:,1] 
auto complete works at this level
I don't get autocomple "value_counts()" 
roster.iloc[:,1].value_counts()

, on the other hand, autocomplete didn't work for pillow library. but it works in the python console. 

I tried with kite integration with spyder. this worked in the spyder Ide. unfortunately, I don't like spyder. would you give me a suggestion or fix it?

0
Comment actions Permalink

@Hafezahmad100

Make sure you use the latest PyCharm version (2020.1.4 at the moment) and if so, file an issue to our issue tracker https://youtrack.jetbrains.com/issues/PY providing code and steps for reproducing the problem.

0
Comment actions Permalink

Me too, i had the exact same issue as you guys having, are you guys had the issue solved yet already?

0
Comment actions Permalink

I have the same problem. Is there a solution?

0
Comment actions Permalink

Kahwoontan Viktor Crettenand

No solution apparently.

Sergey Karpov

This issue still seems to be popping up and not just with pandas.

I'm also getting it with the following:

from xml.dom import minidom

Then when I do `minidom.` I get nothing populating autocomplete.

Pretty annoying...

FYI, this is with PyCharm Pro 2020.2.1

EDIT: Upgraded to PyCharm Pro 2020.3.8 and it's still happening.

 

Seriously, why is this basic feature broken like this and for this long?

Do you know what does work? VS Code. Why does a free program work, but this does not? And please don't tell me "if VS Code works for you, then you should use it" because that doesn't change the fact that a basic feature that's been a part of IDEs since the 90s is not working correctly in PyCharm, and hasn't been working for literal years at this point.

Edit: Adding ticket...

https://youtrack.jetbrains.com/issue/PY-46355

0
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
Avatar
Permanently deleted user
Comment actions Permalink

I am not sure if it is the solution but I uninstalled Kite and disabled the plugging in Pycharm, did the File/Invalidate cache/Restart, closed and reopened the project and now the auto completion is working in the editor for pandas.

0
Comment actions Permalink

Same problem here, this time with numpy and pretty much every other import I've tried. This used to work, then stopped abruptly.

Invalidating caches didn't work.

Uninstalling and reinstalling the latest version of PyCharm didn't work.

Making a new project with a fresh python venv didn't work.

"Power Save Mode" is off. "Collect run-time types information for code insight" is on.

What happens:

What should happen (and what does happen, but only in the console):

0
Comment actions Permalink

Hello @Mem037!

 

Please upload your logs folder zipped from ***Help | Collect logs and Diagnostic Data***   to the FTP

https://uploads.jetbrains.com/ and please let me know the filename. 

 

Quite general steps to try: 

1. Create a new interpreter, test with different python versions

2. Try starting the IDE with default settings as described in https://www.jetbrains.com/help/pycharm/configuring-project-and-ide-settings.html#restore-defaults

0
Comment actions Permalink

Antonina Belianskaya

While I know you were replying to another comment, I can tell you that this is happening to me with a fresh install of PyCharm on newly installed Windows desktops, with various versions of Python, including fresh installs of Anaconda and Python 3.7/3.8/3.9.

 

0
Comment actions Permalink

Hi David, 

Thank you for the details. To proceed with the investigation please submit an issue at https://youtrack.jetbrains.com/issues/PY , with logs folder zipped from ***Help | Collect logs and Diagnostic Data*** , screenshots presenting the behavior. 

Thank you in advance! 

0
Comment actions Permalink

Hi Antonina,

I tried resetting the IDE settings to default. That didn't help.

I've uploaded my logs folder.

Upload ID: 2021_02_22_2whfduS99sF6fFvy (file: pycharm-logs-20210222-120628.zip)

Thanks for looking into this.

0
Comment actions Permalink

Hello @Mem037,

Please try deleting the "Python-stubs" manually: 

C:\\Users\\Marty\\AppData\\Local\\JetBrains\\PyCharm2020.3\\python_stubs. 

If it does not help, please upload a fresh log bundle. Thank you! 

 

It is also worth trying a complete IDE re-installation, with deletion of all IDE related directories before https://www.jetbrains.com/help/pycharm/directories-used-by-the-ide-to-store-settings-caches-plugins-and-logs.html#config-directory

0
Comment actions Permalink

Hi Antonina,

I deleted the "Python-stubs" directory and then let PyCharm rebuild skeletons. It helped...a little bit. Here's what things look like now on my end:

Looks good! Let's try applying a function to Y and then asking PyCharm for code completion options on the result.

Oh. That's not good. Let's check the console to see what things should look like.

I uploaded my logs as requested.

Upload ID: 2021_03_13_UsCNtE9EgSV1BMbN (file: pycharm-logs-20210313-153450.zip)

Thanks for looking into this.

0
Comment actions Permalink

Hello Mem037,

 

Regrettably, this is a bug. I have submitted a ticket https://youtrack.jetbrains.com/issue/PY-47655 please follow it for updates. 

 

I apologize for the inconvenience. 

0
Comment actions Permalink

By the way the same issue has place in Microsoft Visual Studio. It also can't recognize pandas read_excel(....) result as a DataFrame and can't suggest autocomplete options. And it doesn't matter whether it is on python 3.6 or 3.9.

Temporary option is to initialize dataframe as df = pandas.DataFrame(pandas.read_excel(....))

0
Comment actions Permalink

I have the same issue with matplotlib.pyplot

Here is what I see in InteliJ and for comparison what is there in VS Code:

0
Comment actions Permalink

LulaSvob This is a known issue https://youtrack.jetbrains.com/issue/PY-38100

I'm sorry for the inconvenience.

0
Comment actions Permalink

I am having the same problem with autocomplete not working on packages. Currently I just added the lxml package and am importing html. I am trying to use autocomplete and it is not working. I have tried to invalidate caches and restart and deleted the python_stubs thing. You can see the code below... when I type in tree. nothing shows up other than (not, par).

 

import requests
from lxml import html

cl_cat_url = 'https://seattle.craigslist.org/d/farm-garden-services/search/fgs'

params = {
'access_key': '6c1b98133d719f0ab4ff6a6136c41b99',
'url': 'https://seattle.craigslist.org/d/farm-garden-services/search/fgs',
# 'render_js' : 1,
# 'keep_headers' : 1,
'proxy_location' : 'us',
}

headers = {
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.164 Safari/537.36',\
'Accept' : 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',
'Accept-Encoding': 'gzip, deflate, br',
'Accept-Language': 'en-US,en;q=0.9',
'Connection': 'keep-alive',
'Host': 'seattle.craigslist.org',
'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
'sec-ch-ua-mobile': '?0',
'Sec-Fetch-Dest' : 'document',
'Sec-Fetch-Mode': 'navigate',
'Sec-Fetch-Site': 'none',
'Sec-Fetch-User': '?1',
'Upgrade-Insecure-Requests': '1',
}
api_result = requests.get('http://api.scrapestack.com/scrape', params=params, headers=headers )
tree = html.fromstring(api_result.content)

cl_cat_title = tree.
0
Comment actions Permalink

Hi,

I made a video of the described problem I also have with the latest version of PyCharm. As noted by others, auto-completion works in the Python Console but not in the UI.

https://www.youtube.com/watch?v=TJiASf3Uyv8

This example is a simple import of an Excel file using the "openpyxl" package. We then attach a "sheet" in the file and try to auto-complete the "max_row" attribute of this sheet.

In this video you see that:
- In the UI, max_row can be auto-completed when it is called on ws1 object that is a reference to the first sheet in the file
- In the UI, max_row can't be auto-completed when called on the ws2 object that is a named reference to the sheet
- Using the Python Console, we see that the 2 previous tests perfectly work there, "max_row" can be auto-completed on the "ws2" object

So something is different regarding auto-completion in the terminal or in the UI.

I hope this illustrates the problem.

Thanks

0
Comment actions Permalink

Have the same issue. None of the previous suggestions worked smh

0
Comment actions Permalink

The suggestion from Mrtonyy has fixed my issue:

'''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.'''

0

Please sign in to leave a comment.