Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while importing textacy on virtualenv. I am using macosx and python installed in virtualenv. #122

Closed
iporky opened this issue Aug 1, 2017 · 6 comments

Comments

@iporky
Copy link

iporky commented Aug 1, 2017

Traceback (most recent call last):
File "data/test3.py", line 23, in
import textacy
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/textacy/init.py", line 20, in
from textacy import tm
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/textacy/tm/init.py", line 1, in
from .topic_model import TopicModel
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/textacy/tm/topic_model.py", line 10, in
from textacy import viz
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/textacy/viz/init.py", line 1, in
from .network import draw_semantic_network
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/textacy/viz/network.py", line 7, in
import matplotlib.pyplot as plt
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/matplotlib/pyplot.py", line 115, in
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/matplotlib/backends/init.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/Users/shivangchauhan/spaCy/.env/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 19, in
from matplotlib.backends import _macosx
RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
(.env) 1178320-C02SL53UG8WN:spacy shivangchauhan$ brew install python --framework

@bdewilde
Copy link
Collaborator

bdewilde commented Aug 1, 2017

Hi @iporky , that looks to be an issue with your matplotlib installation. Could you try uninstalling then re-installing it within the virtualenv? Also, could you give a full code example that I could use to try and replicate the error?

@iporky
Copy link
Author

iporky commented Aug 1, 2017

hi thanks for the early reply, i imported like this:

from __future__ import absolute_import, division, print_function, unicode_literals

def read_file(file_name):
    with open(file_name, 'r') as file:
        return file.read().decode('utf-8')


from spacy.matcher import Matcher
from spacy.attrs import ORTH, TAG, LOWER, IS_ALPHA, FLAG63
import spacy


from collections import defaultdict
from itertools import takewhile
from operator import itemgetter
import re

from cytoolz import itertoolz
from numpy import nanmin, nanmax, zeros, NaN
from spacy.parts_of_speech import CONJ, DET, NOUN, VERB
from spacy.tokens.span import Span as SpacySpan

import textacy
from textacy import spacy_utils, text_utils
from textacy.compat import unicode_
from textacy.spacy_utils import (normalized_str, get_main_verbs_of_sent,
                                 get_subjects_of_verb, get_objects_of_verb,
                                 get_span_for_compound_noun,
                                 get_span_for_verb_auxiliaries)
from textacy.constants import NUMERIC_NE_TYPES, REPORTING_VERBS

nlp = spacy.load('en')

text = read_file('data/test2.txt')
processed_text = nlp(text)

@iporky
Copy link
Author

iporky commented Aug 1, 2017

i also installed textacy in virtaul env like this:
pip install textacy[all]

@bdewilde
Copy link
Collaborator

bdewilde commented Aug 1, 2017

Okay. Can you import matplotlib separately in this env? Did un- then re-installing the library help?

@iporky
Copy link
Author

iporky commented Aug 1, 2017

hi, i did a complete uninstall and this time used pip install textacy, this seems to work. Ill check with matplotlib and revert back asap!!

@phillbaker
Copy link

For other folks that end up here this issue was helpful: JuliaPy/PyCall.jl#122

for pyenv folks:

env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants