Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autocomplete not working in Pycharm #1682

Closed
Shourai opened this issue Jul 24, 2019 · 11 comments
Closed

Autocomplete not working in Pycharm #1682

Shourai opened this issue Jul 24, 2019 · 11 comments

Comments

@Shourai
Copy link

Shourai commented Jul 24, 2019

While using plotly 4.0 combined with Pycharm the autocompletion for plotly.graph_objects is not working.
Also the references to the objects are not found either, but the script does work.
I see some people on the community site with the same issue.

Untitled
Works fine for e.g. pandas:
Untitled2

No completion is found when I type go. either.

However when I use import plotly.graph_objs as go, the references are found.
But the autocompletion still doesn't work.
I have tried File > Invalidate Cache/Restart, to no avail.

There has been an issue like this before but it seems it had been solved: #389

When I open the same virtualenv within VScode the autocompletion works fine.
(The extension uses jedi for autocompletion I think).
Untitled3

I am not sure if this is an issue with plotly or pycharm.

@jonmmease
Copy link
Contributor

Hi @Shourai, thanks for the report.

What version of PyCharm are you using? I mostly develop plotly.py in PyCharm and I've not seen this problem before. Here's what I get when I create a simple PyCharm project on MacOS with PyCharm version 2019.1.3 with an environment with plotly.py 4.0.0 installed.

Screen Shot 2019-07-25 at 5 41 27 AM

Screen Shot 2019-07-25 at 5 43 32 AM

@Shourai
Copy link
Author

Shourai commented Jul 25, 2019

Hey @jonmmease, thanks for your work on plotly!

The screenshots in the first post were taken on Pycharm 2019.1.3 Professional edition on Windows 10.
I could have sworn it was working before the update to plotly 4.0.
After downgrading plotly to 3.10 it is not working either.

A few minutes after I posted the issue Pycharm version 2019.2 came out, so I thought about removing everything and installing pycharm from scratch without any plugins.
Created a new virtual environment and only installed plotly 4.0
However it still does not work.

Tried it also with Pycharm 2019.2 on a mac running Mojave, no luck there either.

plotly.express is working however.

@cipold
Copy link

cipold commented Jul 25, 2019

Same issue here on PyCharm CE 2018.3 on latest Arch Linux
image
The code executes properly only code completion does not work and the warning is shown.

@jonmmease
Copy link
Contributor

Hi All, I'm still now sure why this is happening for some folks. One thing that we can in 4.2 that might help is that we'll switch things around and output the code generation to the plotly.graph_objects directory, and have the alias point from plotly.graph_objs to plotly.graph_objects instead of the other way around.

@jonmmease jonmmease added this to the v4.2.0 milestone Aug 17, 2019
@nicolaskruchten
Copy link
Contributor

I still wonder if all has something to do with it...

@jonmmease jonmmease removed this from the v4.2.0 milestone Oct 16, 2019
@niklasinde
Copy link

It looks like it has something to do with the graphs_object file being to big:
image

This can be solved (on mac) by going to:

Help > Edit Custom Properties

Then add:

idea.max.intellisense.filesize=500000

Then restart Pycharm
(Stackoverflow link)

After this intellisense worked as expected:
image

@zbl-96
Copy link

zbl-96 commented Dec 2, 2020

the same problem in vscode use pylance language server .anyone have suggest?

@technic
Copy link

technic commented Sep 18, 2021

There is a related issue for pylance microsoft/pylance-release#512
Why this custom relative_import hack is needed?

@technic
Copy link

technic commented Sep 18, 2021

How about changing if guard here
https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/graph_objs/__init__.py
to

if sys.version_info < (3, 7) or TYPE_CHECKING:

this solves an issue with vscode+pylance for me, and in runtime the import is still lazy.
Shall I make a PR?

@JP-Ellis
Copy link
Contributor

Looks like this issue might be a duplicate of #1103 ?

@nicolaskruchten
Copy link
Contributor

This issue will be resolved in the next version of Plotly.py which will come out in a few days, and includes some goodies like #3708 which lets you autocomplete off of the result of functions like px.scatter() as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants