I downloaded a package (called pysolr 2.0.15) to my computer to be used with Haystack. The instructions asks me to add pysolr to my PYTHONPATH.
我将一个包(称为pysolr 2.0.15)下载到我的计算机上,与Haystack一起使用。说明要求我将pysolr添加到我的PYTHONPATH中。
What exactly does that mean? After extracting the pysolr files, I ran the command python setup.py install and that's about it. What did that do and do I need to do anything else?
这到底是什么意思呢?在解压缩pysolr文件之后,我运行了命令python setup.py install,这就是它。做了什么,我需要做什么?
Thanks for the help!
谢谢您的帮助!
2 个解决方案
#1
19
The pythonpath tells python were to look for modules, for example you might have written a library that you want to use in several applications and stored it in the path /mylibs/python/ you would then have to add that path to the pythonpath for python to find it.
pythonpath告诉python要查找模块,例如你可能编写了一个你想在几个应用程序中使用的库并将它存储在路径/ mylibs / python /中你必须将该路径添加到python路径以获取python找到它。
If you've downloaded a python module or library (I'm not really sure about the naming convention here) and you've just saved it in a random place on your computer, then you have to add it to your pythonpath.
如果您已经下载了python模块或库(我不确定这里的命名约定)并且您刚刚将它保存在计算机上的随机位置,那么您必须将它添加到您的pythonpath中。
However if you used easy_install or PIP then you dont have to worry.
但是,如果您使用easy_install或PIP,那么您不必担心。
To add something to the python-path in a *nix system you write:
要在* nix系统中向python-path添加内容,请编写:
export PYTHONPATH=$PYTHONPATH:/<path_to_modules>
#2
5
Maybe, putting a path to pysolr to sys.path will do a work. Put this at settings.py or init.py of your django-project:
也许,将pysolr的路径放到sys.path会做一个工作。把它放在你的django项目的settings.py或init.py上:
PYSOLR_PATH = '/path/to/pysolr/'
import sys
if not PYSOLR_PATH in sys.path:
sys.path.append(PYSOLR_PATH)
sys.path is a list of strings that specifies the search path for modules.
sys.path是一个字符串列表,用于指定模块的搜索路径。
#1
19
The pythonpath tells python were to look for modules, for example you might have written a library that you want to use in several applications and stored it in the path /mylibs/python/ you would then have to add that path to the pythonpath for python to find it.
pythonpath告诉python要查找模块,例如你可能编写了一个你想在几个应用程序中使用的库并将它存储在路径/ mylibs / python /中你必须将该路径添加到python路径以获取python找到它。
If you've downloaded a python module or library (I'm not really sure about the naming convention here) and you've just saved it in a random place on your computer, then you have to add it to your pythonpath.
如果您已经下载了python模块或库(我不确定这里的命名约定)并且您刚刚将它保存在计算机上的随机位置,那么您必须将它添加到您的pythonpath中。
However if you used easy_install or PIP then you dont have to worry.
但是,如果您使用easy_install或PIP,那么您不必担心。
To add something to the python-path in a *nix system you write:
要在* nix系统中向python-path添加内容,请编写:
export PYTHONPATH=$PYTHONPATH:/<path_to_modules>
#2
5
Maybe, putting a path to pysolr to sys.path will do a work. Put this at settings.py or init.py of your django-project:
也许,将pysolr的路径放到sys.path会做一个工作。把它放在你的django项目的settings.py或init.py上:
PYSOLR_PATH = '/path/to/pysolr/'
import sys
if not PYSOLR_PATH in sys.path:
sys.path.append(PYSOLR_PATH)
sys.path is a list of strings that specifies the search path for modules.
sys.path是一个字符串列表,用于指定模块的搜索路径。