当pip install --user时,Python console_scripts不起作用 [英] Python console_scripts doesn't work when pip install --user

查看:214
本文介绍了当pip install --user时,Python console_scripts不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将代码包装到python包中,现在我希望它也可以从命令行(linux)运行.所以我在console.py中添加了console_scripts标签,当我将其作为根安装时似乎一切正常. (我可以从命令行运行程序)

I wrapped my code into python package and now I want it to be also runnable from the command line (linux). So I added console_scripts tag to setup.py and all seems to be working fine when I pip install it as a root. (I can run program from the command line)

但是我也希望使用来安装软件包

However I'd also like for a package to be installed by using

pip install --user.

pip install --user .

,因此当root用户不可用时,可以将其安装在计算机上.但是,当我尝试从命令行调用程序时,出现找不到命令". pip安装成功完成,我仍然可以使用

so it can be installed on computers when root is not available to the user. However when I try to invoke program from the command line i got 'command not found'. The pip installation finishes successfully and I can still run it using

python my_prog.py

python my_prog.py

但是我想知道有没有解决这个问题的办法. 有人可以解释一下console_scripts setup.py标签实际上是如何工作的吗?

But I wonder is there any solution to this problem. Can someone please explain how the console_scripts setup.py tag actually works?

欢迎提出任何想法.

推荐答案

pip将脚本安装在~/.local/bin下.您需要使用以下命令将其添加到您的PATH:

pip installs the scripts under ~/.local/bin. You need to add this to your PATH with:

export PATH=~/.local/bin:$PATH

这篇关于当pip install --user时,Python console_scripts不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆