简体   繁体   中英

pycharm code autocomplete work only in python console but not on python file

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?

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

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, eg 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 eg a script name like code.py which will break autocompletion due to the package code .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM