I have been trying to deploy an app but when triying to call a subprocess python file importing vaderSentiment library it throw me Module not found error.
Traceback (most recent call last):
article_transcript.py", line 2, in <module>
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
ModuleNotFoundError: No module named 'vaderSentiment'
@Goyo Hi thank you for your reply I am attaching a block for your reference to understand better maybe then you could help me solve it
Main App.py
st.set_page_config(
page_title="Watchdog: Let's manage disinformation",
page_icon='Scenes//LogoF-S.png',
layout="wide",
initial_sidebar_state="collapsed",
)
with st.container():
menu, title = st.columns([3,1])
with menu:
selected2 = option_menu(
menu_title=None,
options=["Home", "Case Studies", "Analysis"],
icons=["house", "book", "bar-chart-fill"],
orientation="horizontal"
)
if selected2 == "Analysis":
switch_page('Analysis')
if selected2 == "Case Studies":
switch_page('Casestudies')
with title:
pass
st.title('Watchdog')
st.write('Spreading Awareness')
col1, col2, col3 = st.columns(3)
with col1:
st.subheader("Interactive Visuali")
st.image("Scene.png")
with col2:
st.subheader("Nlling")
st.image("Scenrytelling.png")
with col3:
st.subheader("R Data")
st.image("Sceata.png")
st.divider()
# Create a placeholder for the video link
if "url" not in st.session_state:
st.session_state["url"] = ""
url = st.text_input("Enter the link to the video:", st.session_state["url"])
if url:
st.video(url)
st.session_state["url"] = url
if st.button("Let's Write a Story?"):
try:
subprocess.run(["python", "data_scrapping.py", url])
st.write('We are analysing it in our newsroom')
st.image('Scen.gif')
time.sleep(5)
switch_page('Analysis')
except Exception as e:
st.error(f"An error occurred: {e}")
data_scrapping.py
from j.article_transcript import ArticleTranscript
from j.youtube_transcript import YoutubeTranscript
#from j import youtube_transcript
#from j import article_transcript
import spreadsheet
import requests
import sys
from bs4 import BeautifulSoup
import youtube_transcript_api
# No change needed
def is_url_from_source(url):
'''
Checks if the url comes from a valid source (youtube or one of the article sources).
Returns True if link contains 'youtube' or one of the valid sources. False otherwise.
'''
if 'youtube' in url and is_youtube_valid(url):
return True
else:
article_sources = [source['source'] for source in article_transcript.SOURCES]
for source in article_sources:
if source in url:
return True
return False
def is_youtube_valid(url):
reqs = requests.get(url)
soup = BeautifulSoup(reqs.text, 'html.parser')
if soup.find('meta', itemprop='name') is None:
return False
return True
article_transcript.py
from j.transcript import Transcript
from nltk.sentiment.vader import SentimentIntensityAnalyzer
import requests
from bs4 import BeautifulSoup
from deep_translator import GoogleTranslator
import re
This is where the error shows while running the subprocess
article_transcript.py", line 2, in <module>
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
ModuleNotFoundError: No module named 'vaderSentiment'