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

Installation in Python3? #3

Closed
paoloRais opened this issue Aug 11, 2016 · 2 comments
Closed

Installation in Python3? #3

paoloRais opened this issue Aug 11, 2016 · 2 comments

Comments

@paoloRais
Copy link

Hello,

I am not able to install words2map in Python 3. I get the following error when installing the Python dependencies:

Collecting pattern Using cached pattern-2.6.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> File "/tmp/pip-build-6zmtbvtx/pattern/setup.py", line 40 print n ^ SyntaxError: Missing parentheses in call to 'print'

As far as I know, it is due to the fact that pattern is not supported in Python 3. Is it right? Anything I can do?

@legel
Copy link
Owner

legel commented Aug 11, 2016

Greetings, thanks for bringing this up. I've looked into it, and contacted the pattern authors, and indeed the main distribution of Pattern (which is used for web searching and web scraping) was never fully integrated with support for Python 3. There is an interesting thread you may have seen that presumably led to a working Python 3 distribution, right here.

However, their Travis CI page on its health warns that it doesn't build at least on Python 3.3... I've since added a comment to ask them about that, but also I just quickly tested it on Python 3.4, by creating a conda virtual environment with python 3.4 (using conda create -n python3 python=3.4 anaconda) and running the following:

    git clone https://github.com/pattern3/pattern.git
    cd pattern
    python setup.py install

However, unfortunately, upon testing, their relevant text parsing functions do not seem to work... In their test folder I ran python test_web.py which is what we are using, and the following is a sample of what I got back...

======================================================================
FAIL: test_plaintext (__main__.TestPlaintext)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_web.py", line 455, in test_plaintext
    u"<a href=\"http://www.domain.com\">link</a>\n\n* item1 xxx\n* item2")
AssertionError: 'tags amp; things\n\ntitle1\n\ntitle2\n\nparagr[93 chars]tem2' != 'tags & things\n\ntitle1\n\ntitle2\n\nparagraph[76 chars]tem2'
- tags amp; things

======================================================================
FAIL: test_encode_utf8 (__main__.TestUnicode)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_web.py", line 53, in test_encode_utf8
    self.assertTrue(isinstance(web.encode_utf8(s), str))
AssertionError: False is not true

----------------------------------------------------------------------
Ran 91 tests in 0.500s

FAILED (failures=4, errors=40, skipped=1)                                       357d  ⍉

(python3)

For your sake, and the Python community, I do hope that this can be resolved. But at this time I would advise to watch that issue, and see if you can't engineer a workaround... What I know is that the conda environment that words2map creates can definitely be set to work with Python 2.7 (with all of its baggage that probably led you away from it in the first place). To ensure this, you can just edit the line in install.sh that says:

conda create --name words2map --yes cython scikit-learn gensim seaborn

to be

conda create --name words2map --yes python=2.7 cython scikit-learn gensim seaborn

...and words2map will definitely work for you in that virtual environment.

@paoloRais
Copy link
Author

Thanks for your reply, I will try using it in a Python 2.7 virtual environment then.

@legel legel closed this as completed Aug 15, 2016
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

2 participants