简体   繁体   中英

Cannot import DataFrame in PyCharm

  1. I have installed pandas in my venv. The import statement from pandas import DataFrame is not recognized in Pycharm. DataFrame is underlined with red line. When I run the code, it works fine. Why DataFrame is not recognized.

  2. Also suddenly, relative paths of local packages stopped working in PyCharm but code runs fine though. Absolute path also works fine.

I have tried setting project as "source code" in settings but does not solve the problem.

You might install the DataFrame on your default python environment.

To make sure you have installed on venv environment.

1- Activate your venv either form terminal or command-prompt by execuitng: source ~/envs/venv/bin/activate

2- Install pandas: pip install pandas

Now If you have installed correctly you will have a warning. Otherwise the package will be installed on your venv environment.

  1. File -> invalidate Caches\Restart (did not work)
  2. Removed.idea file and opened project again (did not work)
  3. Pointed project to new venv with all installed dependencies (did not work)

Finally, uninstalled PyCharm and installed again. It solved my problem.

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