pythonvisual-studio-codenltk

How come I can't import nltk even it's already installed successfully?


Hi I tried to install nltk from the vscode terminal which is said to be successful but I am still not able to import nltk on python. It said 'no module named'nltk''.

I attached my screenshot for clearer picture of my work. Thanks!

screenshot


Solution

    1. Make sure that the console enters the environment you are using.

      Since the environment you choose in Jupyter is "myenv":conda, select this environment in the lower left corner of VSCode, and use the shortcut key Ctrl+Shift+` to open a new terminal, VSCode will automatically enter the environment you selected. (You can refer to my screenshot: Result)

    2. Install the module "nltk" in the current environment. pip install nltk or pip3 install nltk

    3. Result:

      enter image description here

    check:

    1. Check the source of the installation tool pip, the installed package is placed in this environment.

      enter image description here

    2. Check the installation package: "pip list"

      enter image description here

    If you encounter any problems, please let me know.