手动安装python包

发布于 2024-12-04 07:57:54 字数 707 浏览 2 评论 0原文

我想使用 https://github .com/erikvold/Github-to-Lighthouse-Issue-Migrator/blob/master/migrator.py 但在第 8 行开始的评论中它说:

# pip install lighthouse-python-api (probably have to do this manually)

但是当我尝试时,我得到了以下错误:

$ pip install lighthouse-python-api
Downloading/unpacking lighthouse-python-api
  Could not find any downloads that satisfy the requirement lighthouse-python-api
No distributions at all found for lighthouse-python-api
Storing complete log in /Users/erikvold/.pip/pip.log

所以我想我需要手动安装该软件包..所以有人可以解释或链接到解释如何执行此操作的文档吗?

I'd like to use https://github.com/erikvold/Github-to-Lighthouse-Issue-Migrator/blob/master/migrator.py but in the comments starting on line 8 it says:

# pip install lighthouse-python-api (probably have to do this manually)

But when I try I get the following error:

$ pip install lighthouse-python-api
Downloading/unpacking lighthouse-python-api
  Could not find any downloads that satisfy the requirement lighthouse-python-api
No distributions at all found for lighthouse-python-api
Storing complete log in /Users/erikvold/.pip/pip.log

so I guess I need to install the package manually.. so can someone plz explain or link to docs that explain how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

掀纱窥君容 2024-12-11 07:57:54

正如 @delnan 所说,Lighthouse API 的维护者应该真正创建一个 setup.py 脚本。无论如何,有两种方法可以实现你想要的,并且都需要了解 python 模块。

当您像这样在 python 中导入模块时:

import lighthouse

解释器在运行输入脚本的目录中搜索名为 lighthouse.py 的文件,如果在那里找不到该文件,则会在环境变量 PYTHONPATH 指定的目录中搜索。如果您不知道什么是环境变量,我建议您在这里阅读它们:http://en。 wikipedia.org/wiki/Environment_variable

如果在 PYTHONPATH 环境变量指定的目录中找不到它,则默认为依赖于安装的 sys.path 变量。

Lighthouse 的维护者正在做的事情(我认为)是将这些文件从他下载到的任何目录中符号链接到他的安装默认目录中。您可以通过运行 python 解释器并查看 sys.path var 来快速找出该目录是什么:

>>> sys.path
['', '/usr/local/lib/python2.6/dist-packages/Paste-1.7.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/tornado-1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pymongo-1.10.1-py2.6-linux-x86_64.egg', '/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_debug_toolbar-0.8.5-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']

您可以看到 /usr/local/lib/pthon2.6/dist- packages/ 是所有模块所在的文件夹。我相信这是维护者对其文件进行符号链接的地方。 这不是一个好主意。您不应该直接修改它。

更好的方法是简单地下载文件并将它们放在与脚本相同的目录中,或者应该将它们放在一个目录中并将该目录添加到 PYTHONPATH 环境变量中。

As @delnan said, the maintainer of Lighthouse API should really create a setup.py script. Anyway, there are two ways to achieve what you want and both require an understand of python modules.

When you import a module in python like so:

import lighthouse

the interpretor searches for a file named lighthouse.py in the directory which the input script was run and if it cannot find it there it then searches in the directories specified by the environment variable PYTHONPATH. If you do not know what an environment variable is, I suggest reading up about them here: http://en.wikipedia.org/wiki/Environment_variable

If it can't find it in the directories specified by the PYTHONPATH envi var it then defaults to the sys.path var which is installation dependent.

What the maintainer of lighthouse is doing (I think) is symlinking these files from whatever directory he downloaded them to into his installation default directory. You can quickly figure out what this directory is by running the python interpretor and looking at the sys.path var:

>>> sys.path
['', '/usr/local/lib/python2.6/dist-packages/Paste-1.7.5.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/tornado-1.1-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/pymongo-1.10.1-py2.6-linux-x86_64.egg', '/usr/local/lib/python2.6/dist-packages/mongoengine-0.4-py2.6.egg', '/usr/local/lib/python2.6/dist-packages/django_debug_toolbar-0.8.5-py2.6.egg', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/local/lib/python2.6/dist-packages', '/usr/local/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0']

You can see that /usr/local/lib/pthon2.6/dist-packages/ is the folder all the modules are in. I believe this is where the maintainer is symlinking his files. THIS IS NOT A GOOD IDEA. You shouldn't modify this directly.

The better approach is to simply download the files and place them in the same directory as your script, or you should place them in a directory and add that directory to the PYTHONPATH environment var.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文