Newspaper Package error download in Python/Pip (Google Colaboratory) - python

I am trying to perform sentiment analysis on an article from Wikipedia. I need to use the newspaper Python package and am having difficulties implementing it into my code. I have downloaded pip from the terminal and opened the venv virtual environment, and downloaded nltk, textblob, and newspaper3k. However, when I go to run the code it says no such newspaper module exists even though I have downloaded it from the terminal multiple times? I have updated pip and reran my code, but am receiving the same error. What could I do to resolve the issue?
Thank you!
I have tried researching the issue, I opened a virtual environment and downloaded the packages inside that. Along with that I updated pip and reran the code, and tried downloading newspaper3k multiple different times with the same result. I am using Google Colaboratory to run code.
Here is the error I am receiving.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-71f9b211be5a> in <module>
1 from textblob import TextBlob
----> 2 from newspaper import Article
3
4 url = 'https://en.wikipedia.org/wiki/Mathematics'
5
ModuleNotFoundError: No module named 'newspaper'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-8-71f9b211be5a> in <module>
1 from textblob import TextBlob
----> 2 from newspaper import Article
3
4 url = 'https://en.wikipedia.org/wiki/Mathematics'
5
ModuleNotFoundError: No module named 'newspaper'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
But in the terminal, I have downloaded newspaper3k:
Requirement already satisfied: six in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from feedfinder2>=0.0.4->newspaper3k) (1.15.0)
Please let me know what I could do to resolve the error I receive in Google Colaboratory - I am unclear what is causing it since I have downloaded the packages. I suspect the error might be caused with the directory I imported the modules in and the directory of the Google Colaboratory file not matching -- I created 2 virtual environments and downloaded the modules in those. I am not sure which directory my google colaboratory file is in and whether or not it matters if it is in the same directory as the modules. If this is the case, how would i go about to move the Colaboratory file to the same directory?
Thank you so much!

Related

I receive ModuleNotFoundError only when the package is downloaded from PyPI

I am working on a Back Up system named RunUp - Is still on a very early stage.
You can see all the source code on its GitHub page. And also, I uploaded it to PyPI, so, probably you won't have any problem to see what is happening by your self.
Well, this is the thing:
If you download the repo, move to the root, create your virtual environment and run pip install --editable . (do not omit the dot), you will see that the installation runs well and if you use runup --version it will show the output RunUp, version 0.1.dev4. Everything is OK.
But...
If you open a new console (or uninstall the package) and download it directly from PyPI with pip install runup, it will be installed without problem but when you use it (running again runup --version) it will output an error message:
Traceback (most recent call last):
File "/home/user/path/to/repo/venv/bin/runup", line 5, in <module>
from src.runup.cli import cli
ModuleNotFoundError: No module named 'src'
I don't know very well why this is happening but I may think that is related to my setuptools implementation or the directory tree. Not really sure about that.

Running Jupyter Notebook on Binder with spacy dependencies

I want to try out spacy in a Jupyter Notebook using Binder. When trying to run load on a model like:
nlp = en_core_web_sm.load()
I get the following error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-8a5aa70d40b9> in <module>
----> 1 import en_core_web_sm
2 nlp = en_core_web_sm.load()
ModuleNotFoundError: No module named 'en_core_web_sm'
I tried downloading the model using the requirements.txt, but that didn't work or the model was download in an area I don't have access to. Not sure.
Here's the Github repo. Thank you.
It looks like you are trying to use environment.yml and requirements.txt. When your needs necessitate moving beyond a requirements.txt configuration file for Binderhub-served sessions, you should move the contents of requirements.txt to environment.yml following this example repo. In your case though one of your current requirements.txt lines is redundant (and conflicting) with the spacy line in environment.yml.
spaCy models are not installed using the requirements.txt. You have to install them in your environment by running
python -m spacy download en_core_web_sm
For more information, see https://spacy.io/usage/models.

Jupyter notebook error ModuleNotFoundError: No module named 'datascience'

Good evening,
I am trying to import datascience module at my Jupyter notebook, but the notebook keeps showing error called
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-10-6f3a305c96af> in <module>()
----> 1 from datascience import *
ModuleNotFoundError: No module named 'datascience'
although I have done
pip install --user datascience
Could anyone solve this problem for me?
Thank you in advance
first, check whether you have installed datascience package in to the same environment.
use pip freeze to list installed packages.
if it's installed correctly, then try this.
import datascience as dt
then you can access ant function in datascience package.
`dt.function()`
Perhaps these links can help you :
link, link 2 and link 3
First, activate your environment if you have it.
Second, check your project path.
Third, try to install your package one more time.
Fourth, use freezing to check if a module is installed.
Five, check if the import is well done.

pip Installed biopython, but it won't compile Bio Module

I have biopython installed, but it keeps saying no module named Biopython
I had this working previously so I know it works, but I wanted the program to compile on a different computer. I installed python on the computer (version 3.7.3) and installed Pycharm Community Edition as the IDE. After that I installed pip and did the following in the pycharm terminal:
pip install biopython
Output:
Requirement already satisfied: biopython in c:\users\thisi\appdata\local\programs\python\python37\lib\site-packages (1.73)
Requirement already satisfied: numpy in c:\users\thisi\appdata\local\programs\python\python37\lib\site-packages (from biopython) (1.16.4)
Yet, whenever I compile the program, I get the following error.
C:\Users\thisi\AppData\Local\Programs\Python\Python37\python.exe C:/Users/thisi/Desktop/H-protein/py-scripts/protein-blastp.py
Traceback (most recent call last):
File "C:/Users/thisi/Desktop/H-protein/py-scripts/protein-blastp.py", line 1, in <module>
from Bio.Blast.Applications import NcbiblastpCommandline
ModuleNotFoundError: No module named 'Bio'
Process finished with exit code 1
I have browsed the internet for hours to find a solution, but none seem to work as they are tailored to linux.
Other Relevant Details:
My OS is Windows10
If I open the project interpreter, it shows biopython package installed in my current project and python 3.7 as the interpreter. Any help would be appreciated.
from Bio.Blast.Applications import NcbiblastpCommandline
I just need the first line of code to compile
The function I gave is an example of how I use the biopython package

Importing error in python package skimage

I want to use skimage.restoration.denoise_wavelet to denoise a image. But problem occurs on importing.
from skimage.restoration import denoise_nl_means,denoise_wavelet
ImportError Traceback (most recent call last)
<ipython-input-2-161a32d32528> in <module>()
----> 1 from skimage.restoration import denoise_nl_means,denoise_wavelet
ImportError: cannot import name denoise_wavelet
There is no problem in importing denoise_nl_means which is in the same category with denoise_wavelet. It doesn't make sense.
I used pip for installing and updating the skimage package and jupyter notebook for coding.
I installed all requirements before installing scikit-image 0.12.3. The requirement items I installed were:
matplotlib 1.5.1,numpy 1.11.1,scipy 0.18.1,six 1.10.0,networkx 1.11,pillow 3.4.1,dask 0.10.0,PyWavelets 0.4.0.
As you installed this library with pip, it probably installed the latest stable release, which is something within the 0.12 branch.
There are different documentations for different versions of scikit-learn.
The function which you want to import does not exist yet in any stable branch if we interpret the following correctly:
Search for function-name in docs of development-branch: OK!
Search for function-name in docs of 0.12 branch No hits!
Sadly, the docs of scikit-image do not say when a function was added to the library (as done by scipy).
Further analysis can be done on github + blame here.
So if you need this function, grab the development-branch and install from sources! Always read the corresponding doc-versions!
used the following command:
pip install -U https://github.com/scikit-image/scikit-image/archive/master.zip

Categories