How to use multiple versions of Python without uninstallation

前端 未结 15 1567
醉梦人生
醉梦人生 2021-02-05 14:11

I am faced with a unique situation, slightly trivial but painful.

I need to use Python 2.6.6 because NLTK is not ported to Python 3 (that\'s what I could gather).

15条回答
  •  醉梦人生
    2021-02-05 14:54

    The OP request is a little outdated, especially now that NLTK does have a py3.x port. see Install nltk 3.0 on Ubuntu 13.10 using tar.gz download

    Here's how you can get python3 to work with NLTK.

    $ sudo apt-get install python3-pip
    $ sudo pip3 install pyyaml
    $ wget http://www.nltk.org/nltk3-alpha/nltk-3.0a3.tar.gz
    $ tar -xzvf nltk-3.0a3.tar.gz
    $ cd nltk-3.0a3/
    $ sudo python3 setup.py install
    $ python3
    >>> import nltk
    >>> from nltk.corpus import brown
    >>> print(brown.sents()[0])
    ['The', 'Fulton', 'County', 'Grand', 'Jury', 'said', 'Friday', 'an', 'investigation', 'of', "Atlanta's", 'recent', 'primary', 'election', 'produced', '``', 'no', 'evidence', "''", 'that', 'any', 'irregularities', 'took', 'place', '.']
    

提交回复
热议问题