tsroten / pynlpir

A Python wrapper around the NLPIR/ICTCLAS Chinese segmentation software.
MIT License
566 stars 135 forks source link

Bug when running the tutorial code on mac osx. #37

Closed Titansonia closed 8 years ago

Titansonia commented 8 years ago

Hello, i'm using mac os x, and i've just successfully installed pynlpir-0.4 on my mac, however, when i tried the simple example in your tutorial, code is like below:

coding=utf-8

import pynlpir pynlpir.open() s = '欢迎科研人员、技术工程师、企事业单位与个人参与NLPIR平台的建设工作。' pynlpir.segment(s) pynlpir.close()

Some error message showed like below: /System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7 /Users/titansonia/PycharmProjects/spider_v1.1/word_seg.py

[2015-12-28 15:45:36] Cannot open file Cannot write log file /Library/Python/2.7/site-packages/pynlpir/Data/20151228.err! [2015-12-28 15:45:36] /Library/Python/2.7/site-packages/pynlpir/Data/KeyBlackList.pdat Cannot write log file /Library/Python/2.7/site-packages/pynlpir/Data/20151228.err! [2015-12-28 15:45:36] Cannot open file /Library/Python/2.7/site-packages/pynlpir/Data/NewWord.lst Cannot write log file /Library/Python/2.7/site-packages/pynlpir/Data/20151228.err!

Process finished with exit code 0

I don't know why, cause the installation process went on well also. Please help me..

lomizandtyd commented 8 years ago

Sorry, I didn't use mac os before.


But it seems like you don't have the permission of the directory: /Library/Python/2.7/site-packages/pynlpir/

Did you install it in super user? Try to run the test code in super user.


If so, try

sudo pip uninstall pynlpir

Then Download the zip file, and unzip it. or just

git clone https://github.com/tsroten/pynlpir.git

Assume the directory is

some_name\
        |------------pynlpir\
                           |--------------setup.py

then

cd some_name
sudo pip install -e ./pynlpir
Titansonia commented 8 years ago

Thank u~ That's it

tsroten commented 8 years ago

@Titansonia On a Mac, you might consider installing an updated version of Python (it includes pip) through homebrew. That way you don't ever need to mess with sudo when you install or run Python packages.

  1. Install homebrew by running this in the terminal:
    ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  2. Install an updated version of Python: brew install python or brew install python3
  3. Now install PyNLPIR: pip install pynlpir or pip3 install pynlpir