8

I have Anaconda environment on my machine for python 3.6 When I try to install pattern package through pip, it gave an error saying something like

parentheses around print n

Then I tried conda install -c asmeurer pattern=2.5; as well as conda install -c asmeurer pattern. It says

UnsatisfiableError: The following specifications were found to be in conflict: - pattern -> python 2.7* - python 3.6*"

Finally, I got to know that python 3 does not have pattern directly.

So, I tried downloading pattern zip from http://www.clips.ua.ac.be/pattern. Now, when I ran python ./setup.py install. It again give errors related to parentheses around print n

I have tried almost everything, but unable to install pattern package in my python 3.6 Anaconda environment. Can someone please help me out here , some workaround for this?

rock321987
  • 10,942
  • 1
  • 30
  • 43
jatin kinra
  • 103
  • 2
  • 6

3 Answers3

10

I installed PIP with Conda

conda install pip

and then installed Pattern with

pip install Pattern3

it worked :)

Masume Ebhami
  • 348
  • 1
  • 14
  • Are you using python 3.6 ? – jatin kinra May 29 '17 at 05:45
  • Collecting Pattern Using cached pattern-2.6.zip Complete output from command python setup.py egg_info: Traceback (most recent call last): File "", line 1, in File "C:\Users\jatin\AppData\Local\Temp\pip-build-r_d_2wek\Pattern\setup.py", line 40 print n ^ SyntaxError: Missing parentheses in call to 'print' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in C:\Users\jatin\AppData\Local\Temp\pip-build-r_d_2wek\Pattern\ – jatin kinra May 29 '17 at 05:47
  • I tried that too. But getting the same error as mentioned in above comment. Also, it says "using cached pattern-2.6.zip". can that be an issue ? – jatin kinra May 29 '17 at 05:51
  • the error because of Pattern 2.6 not compatible with Python 3 – Masume Ebhami May 29 '17 at 05:53
  • So, what is the solution for this? I am not even mentioning the package version. – jatin kinra May 29 '17 at 05:56
  • There are really only two fixes to this problem: Use version 2.x instead, or find a library built for version 3.x. – Masume Ebhami May 29 '17 at 05:59
  • Sorry, but you mentioned that you were able to install it for python 3.6. The library you got must be compatible with 3.x right ? – jatin kinra May 29 '17 at 06:04
  • Yes i am sorry i forgot mention that i use pattern3 instead of pattern – Masume Ebhami May 29 '17 at 06:05
  • pip install Pattern3 worked. Thanks a lot for ur help Masume. You saved me a ton of time. Really appreciate it. Thanks again :-) – jatin kinra May 29 '17 at 06:15
5

I'm not sure how this relates to Anaconda, but this worked for me to get pattern.en working in python 3.6:

git clone -b development https://github.com/clips/pattern
cd pattern
sudo python3.6 setup.py install

https://github.com/clips/pattern/issues/62

I had some SSL errors during installation on my mac (10.11.6) that were fixed by running this code in python (3.6):

import nltk
import ssl 

try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

nltk.download('wordnet_ic')

apparently there's a better way to deal with ssl stuff like this fwiw: https://stackoverflow.com/a/41351871/8870055

sanity check:

user@USDR00253 ~> python3.6
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> from pattern.en import conjugate, lemma, lexeme, parse
>>>
>>> print(parse('ridden', relations=True, lemmata=True))
ridden/VBN/B-VP/O/O/ride
>>>

pattern.en finally running in python3!

stuart
  • 1,785
  • 2
  • 26
  • 38
0

Using Windows Subsystem for Linux, I made pattern to work using miniconda in Python 3.7:

conda create -n test -c conda-forge python=3.7 pattern
conda activate test

I discovered that there is a bug with StopInteration due to PEP-479, and replacing raise StopIteration with return in pattern\text\__init__.py fixes it.

To find the location if the file, I executed

cd $(python -c "from distutils.sysconfig import get_python_lib;print(get_python_lib())")
nano pattern/text/__init__.py

Line 605, just above class Lexicon(lazydict): ... replace raise StopIteration with return.

And all is working fine.

enter image description here

Prayson W. Daniel
  • 14,191
  • 4
  • 51
  • 57