Tried to follow this line of code from this link https://spacy.io/universe/project/spacy-sentence-segmenter to create a sentence segmenter. Encountered the following error:ModuleNotFoundError: No module named 'seg'.
Spacy already installed. Didn't find any information about which module should be used for this 'seg'. Anyone could help? thanks.
from seg.newline.segmenter import NewLineSegmenter
import spacy
nlseg = NewLineSegmenter()
nlp = spacy.load('en')
nlp.add_pipe(nlseg.set_sent_starts, name='sentence_segmenter', before='parser')
doc = nlp(my_doc_text)
Sentence Segmenter is a third-party module that is different from your spaCy installation. You need to install it separately:
pip install spacyss
You can find more information in the project's Github page.
Try to install the module using pip or pip3: pip3 install segmentation
Related
I'm trying to use Spacy for pos tagging in Spanish, for this I have checked the official documentation and also have read various post in Stackoverflow nonetheless neither has worked to me.
I have Python 3.7 and Spacy 2.2.4 installed and I'm running my code from a jupyter notebook
So as documentation suggests I tried:
From my terminal:
python -m spacy download en_core_web_sm
This gave the result:
Download and installation successful
Then in my jupyter notebook:
import spacy
nlp = spacy.load("es_core_news_sm")
And I got the following error:
ValueError: [E173] As of v2.2, the Lemmatizer is initialized with an instance of Lookups containing the lemmatization tables. See the docs for details: https://spacy.io/api/lemmatizer#init
Additionally, I tried:
import spacy
nlp = spacy.load("es_core_news_sm")
And this gave me a different error:
OSError: Can't find model 'es_core_news_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory
Could you please help me to solve this error?
You downloaded English model. In order to use Spanish model, you have to download it python -m spacy download es_core_news_sm
After downloading the right model you can try import it as follow
import spacy
import es_core_news_sm
nlp = es_core_news_sm.load()
from mailmerge import MailMerge
ModuleNotFoundError: No module named 'mailmerge'
Pease help on this
https://pypi.org/project/docx-mailmerge/#files
Do you have mailmerge installed? There aren't many details you're giving us here.
Try pip install docx-mailmerge
Otherwise download the .whl file in the link provided and place it in the correct path.
Then you can do pip install [location of file].whl
Unless you supply more info, that's all I can tell you.
Although it has been a while
for me was the solution to uninstall the module "mailmerge"
and after that it worked.
I can't seem to use a module in Jupyter notebooks that was successfully installed to my mac via pip3 install geopy.
I do not understand anything about working directory, where the module is being sent after download, or where jupyternotebooks is grabbing modules when you import them. Please help
import geopy
ModuleNotFoundError: No module named 'geopy'
If you want to use a particular package in a jupyter notebook you can use the following command in a code cell in a jupyter notebook.
!pip install geopy
In the next code cell you can try
import geopy
This will at the least ensure you have the package to use within the jupyter notebook.
You may want to read this text for details on python and pip
well i am trying to use community detection algorithms by networkx on famous facebook snap data set.
here are my codes :
import networkx as nx
import matplotlib.pyplot as plt
from networkx.algorithms import community
from networkx.algorithms.community.centrality import girvan_newman
G_fb = nx.read_edgelist("./facebook_combined.txt",create_using = nx.Graph(), nodetype=int)
parts = community.best_partition(G_fb)
values = [parts.get(node) for node in G_fb.nodes()]
but when i'm run the cell i face with the title error which is :
AttributeError: module 'networkx.algorithms.community' has no attribute 'best_partition'
any advice ?
I think you're confusing the community module in networkx proper with the community detection in the python-louvain module which uses networkx.
If you install python-louvain, the example in its docs works for me, and generates images like
Note that you'll be importing community, not networkx.algorithms.community. That is,
import community
[.. code ..]
partition = community.best_partition(G_fb)
I faced this in CS224W
AttributeError: module 'community' has no attribute 'best_partition'
Pls change this file karate.py
replace import to
import community.community_louvain as community_louvain
then it works for me.
I had the same problem. In my case, it was solved importing the module in a different manner:
import community.community_louvain
Source
I also faced this in CS224W
but changing the karate.py or other solutions didn't work.
For me (in colab) using the new PyG installation code worked.
this code, will install the last version:
!pip install -q torch-scatter -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html
!pip install -q torch-sparse -f https://pytorch-geometric.com/whl/torch-1.9.0+cu102.html
!pip install -q git+https://github.com/rusty1s/pytorch_geometric.git
I had a similar issue.
In my case, it was because on the other machine the library networkx was obsolete.
With the following command, the issues was solved.
pip3 install --upgrade networkx
I naively thought that pip install community was the package I was looking for but rather I needed pip install python-louvain which is then imported as import community.
This has helped me to run the code without errors:
pip uninstall community
import community.community_louvain as cl
partition = cl.best_partition(G_fb)
I'm relatively new to python, so please excuse my ignorance on what could be a very easy fix. I am running python 3.6 through the Rodeo IDE, and it has been great, as it is similar to R-Studio (which I am very familiar with). As an aspiring data scientist, I am trying to learn how to fit regression and time series models to data, and all of the tutorials that I have found all say that I need various packages, all of which should be included in the Anaconda library. After downloading and re-downloading Python, Rodeo, and Anaconda, and trying various online fixes, I have been unable to successfully load the scikit-learn and the statsmodels modules.
#here is everything I have tried.
#using pip
! pip install 'statsmodels'
! pip install 'scikit-learn'
! pip install 'sklearn'
I don't get any errors here, and to be honest I'm kind of confused as to what this actually does, but I have seen many people online always suggest that this is a big problem when trying to import modules.
#using import
import sklearn
import statsmodels
from sklearn import datasets
import statsmodels.api as sm
all of the above give me the same error:
import statsmodels.api as sm
ImportError: No module named 'statsmodels'
ImportError: Traceback (most recent call last)
ipython-input-184-6030a6549dc0 in module()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'
I have tried to set my working directory to the Anaconda 3 file that has all of the packages and rerunning the above code with no success.
I'm thinking that the most likely problem has to do with my inexperience, and it is probably a simple fix. Is it possible that the IDE is bad or anaconda just doesn't like me?
So keeping all of the above in mind, the question is, how can I import these modules successfully so that I can access their functionality?
Option 1:
After installing packages with pip, try closing and reopening your IDE/Jupyter Notebook and try again.
This is a known bug that Jake VanderPlas outlined here
Option 2:
Don't put quotations around your pip messages.
!pip install -U statsmodels
!pip install scikit-learn
Option 3:
Also are you using Anaconda? If you are, you should already have scikit-learn. If you are trying inside Rodeo, I think you need to set your path inside Rodeo. Open Rodeo and set the Python Path to your fresh anaconda. See here