I have just started learning NLP and for that purpose I installed nltk package using pip install nltk in the cmd terminal of VS Code. After I installed it, I tried importing it in the command line itself and I was successful but in the main window where we write the code, I tried from nltk.tokenize import sent_tokenize but it showed the following error:
then I tried simply import nltk but that too didn't work, and it showed the following error:
I also tried restarting VS Code, but it was all in vain. How can I resolve this issue?
Related
I'm a beginner level Python user. Up until today I was able to use installed packages(pandas, numpy and so on) at PyCharm. I try to download BeautifulSoup and error msg took me to PyCharm web site. I followed instruction on my regular MacBook terminal (macOS Monterey 12.4) where it told me to upgrade the pip as pip3 and try the pip3 install beautifulsoup. After this code I get this from terminal Requirement already satisfied.
However since that update on terminal none of the packages on my PyCharm are working. PyCharm marks it with red underline, I click and choose install again but still not working. This is what I get
Traceback (most recent call last):
File "/Users/ezgiwon/PycharmProjects/pythonProject1/main.py", line 1, in <module>
from bs4 import beautifulsoup4
ModuleNotFoundError: No module named 'bs4'
Also for the rest it's similar to this error couldn't find __innit__.py
I've read so many solutions here but some didn't work some I wasn't able to understand with my current knowledge.
I tried the 'edit configurations', 'edit python interpreter',also tried the built-in PyCharm terminal to upload those packages. I'm not sure how to fix this issue. I thought I could delete everything following a tutorial and start fresh but seems like I didn't clear all past files.
Now I have a new file under Library/Framework for Python which I will be asking in separate question.
Please try to guide me as detailed as possible, much of these terms are new to me and really struggling to run PyCharm correctly. I really need it to run for simple study tasks as I was using it for very basic pandas and numpy calculations.
[interpreter][1]
[Paths][2]
[interpreter2][3]
Run in terminal:
pip install beautifulsoup4
Then import like this
from bs4 import BeautifulSoup
I'm trying to use pyheif in Windows. For that, I've tried following this solution, provided Yienschwen.
It worked so far as I was able to run pip install pyheif without any problem.
However, now, I'm trying to import pyheif, and I get the following error:
I can't find that file anywhere on the internet...
SOLVED
I'm trying to import the rich python library into my script, but it isn't working.
I was able to install it with
pip install rich but my script doesn't seem to recognize it as being installed.
To make sure it was installed I ran python -m rich which displays all of the features rich adds, and that ran correctly as well.
But if we look in my script where it's being imported, there's an error line below rich saying it isn't recognized. Specifically it says that "Import 'rich' could not be resolved"
screenshot of the import line
Has anyone encountered this before?
SOLUTION
Had to restart visual studio code and it fixed it
So I was working on an AI voice assistant and I tried importing the speech_recognition module into my code but it didn't work.
I installed the module using:
pip install SpeechRecognition
It got installed correctly.
Then when I tried to import the module using:
import speech_recognition as sr
The name of the module wasn't auto suggested or highlighted while typing so I'm assuming the interpreter was unable to find the module.
And none of the functions I called got highlighted either and gave an error on execution. Any idea how I can fix this?
I think there is two ways of trying to solve this
1- Try Restarting your Editor
2- Try this:
python -m pip install SpeechRecognition
then restart the Editor.
I recently got a new computer and installed VSC as well as the official python on it. I installed some extra libraries for python on it with pip but whenever I want to run a script it gives me the error: ModuleNotFoundError: No module named 'numpy', or any other library installed afterwards. The libraries that come with python do work.
When I run the same script in IDLE for example, all the libraries are found and it works fine, but I would like to be able to code in VSC.
For example:
import numpy as np
import pygame as pg
import time
Rest of the code...
The error occurs right when it tries to import the libraries.
Any ideas on what might be causing the problem?