0

I am trying to include a package for which i installed using the cmd window and pip. It installed successfully however when i go to use it in Pycharm it returns an error saying the package is not installed. When I try to install it using Pycharm it fails.

Is there any way to get Pycharm to recognize the package that is installed already?

enter image description here

Hiba Youssef
  • 397
  • 5
  • 12
  • 3
    You probably installed the packages in your system python, but you're working with a virtual environment; just use PyCharm package manager to install packages and you'll be fine – crissal Jun 07 '21 at 09:31

2 Answers2

2

PyCharm does not use the same python interpreter as the one you installed package for.
As @crissal said, you can use PyCharm package manager to install packages, or configure it to recognize the one you already have:

  1. In your cmd, type which python and you'll get something like /usr/bin/python (on win it might be different but doesn't matter). That's the path of your default interpeter.
  2. In PyCharm: Preferences -> Project -> Python Interpreter
  3. Choose path if listed, or Show all -> + -> find and select path
  4. Now in top right corner of the window, next to run button, select interpeter dropdown and Edit configuration
  5. Select correct Python interpreter, give it a few moments PyCharm will figure out your nltk dependency

I would strongly suggest using virtual environment for each project, in order not to mix dependencies.

nenadp
  • 601
  • 1
  • 5
  • 13
0

first uninstall nltk then try to install it from the PyCharm command line using the same interpreter.

Sandeep Agrawal
  • 133
  • 1
  • 7