简体   繁体   English

我不知道MacOS上这些第三方Python软件包的安装位置?

[英]I don't know where those third-party Python packages have been installed on MacOS?

I'm currently doing Natural Language Processing with Python. 我目前正在使用Python进行自然语言处理。 I installed NLTK package by using pip install nltk . 我通过使用pip install nltk安装了NLTK软件包。 I have several Pythons on my Mac, but I use 3.4 mostly. 我的Mac上有多个Python,但我大多使用3.4。

Now, I've downloaded a segmenter from Stanford that could do Chinese language segmentation( Stanford Word Segmenter ), but it might need me to do some changes on the original NLTK package, namely, I have to write an API file called stanford_segmenter.py and then put it into the nltk/tokenize/ directory. 现在,我从斯坦福( Stanford )下载了一个可以进行中文细分的细分器( Stanford Word Segmenter ),但是可能需要我对原始NLTK软件包进行一些更改,即,我必须编写一个名为stanford_segmenter.py的API文件。然后将其放入nltk/tokenize/目录。

The problem is I don't really know where the NLTK package having been installed, I actually don't know where the lib directory of Python 3.4 is on MacOS. 问题是我真的不知道NLTK软件包的安装位置,我实际上也不知道Python 3.4的lib目录在MacOS上的位置。 Anyone could help me? 有人可以帮助我吗?

A generic approach to locating a package in the file system is importing it and looking at the __file__ attribute. 在文件系统中定位包的一种通用方法是将其导入并查看__file__属性。

On the commandline, you can eg run 在命令行上,您可以例如运行

python -c "import nltk; print(nltk.__file__)"

It will show you where the top level nltk (probably __init__.py ) file is located. 它将显示顶级nltk (可能是__init__.py )文件的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM