pip 成功安装软件包,但未从命令行找到可执行文件 [英] pip installs packages successfully, but executables not found from command line

查看:29
本文介绍了pip 成功安装软件包,但未从命令行找到可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 mac OS X Yosemite,版本 10.10.3.

I am working on mac OS X Yosemite, version 10.10.3.

我使用 macport 安装了 python2.7 和 pip,如在http://johnlaudun.org/20150512-installing-and-setting-pip-with-macports/

I installed python2.7 and pip using macport as done in http://johnlaudun.org/20150512-installing-and-setting-pip-with-macports/

我可以成功安装包并将它们导入到我的 python 环境和 python 脚本中.但是,找不到与可以从终端中的命令行调用的包相关联的任何可执行文件.

I can successfully install packages and import them inside my python environment and python scripts. However any executable associated with a package that can be called from the command line in the terminal are not found.

有人知道哪里出了问题吗?(更多详情见下文)

例如,在按照 http://wiki.ros 中的说明安装名为rosdep"的软件包时.org/jade/安装/源

我可以运行:sudo pip install -U rosdep安装没有错误,相应的文件位于 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

I can run: sudo pip install -U rosdep which installs without errors and corresponding files are located in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

但是,如果我尝试运行:sudo rosdep init,它给出了一个错误:"sudo: rosdep: command not found"

However if I try to run : sudo rosdep init, it gives an error : "sudo: rosdep: command not found"

这不是特定于包的错误.对于在我的计算机上使用 pip 安装的任何软件包,我都会得到这个.我什至尝试添加

This is not a package specific error. I get this for any package installed using pip on my computer. I even tried adding

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages

到我的$PATH.但是在命令行上找不到可执行文件,即使这些包在 python 中运行良好.

to my $PATH. But the executables are not found on the command line, even though the packages work perfectly from within python.

推荐答案

检查您的 $PATH

tox 有命令行模式:

audrey:tests jluc$ pip list | grep tox
tox (2.3.1)

它在哪里?

(2.7 的东西在这里无关紧要,在任何 3.x 和 pip 的行为都差不多)

(edit: the 2.7 stuff doesn't matter much here, sub in any 3.x and pip's behaving pretty much the same way)

audrey:tests jluc$ which tox
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/tox

我的 $PATH 中有什么?

and what's in my $PATH?

audrey:tests jluc$ echo $PATH
/opt/chefdk/bin:/opt/chefdk/embedded/bin:/opt/local/bin:..../opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin...

注意 /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin?这就是允许找到我的 pip 安装的东西

Notice the /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin? That's what allows finding my pip-installed stuff

现在,要查看 Python 中的内容,请尝试执行此操作(将 rosdep 替换为 tox).

Now, to see where things are from Python, try doing this (substitute rosdep for tox).

$python
>>> import tox
>>> tox.__file__

打印出来:

'/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tox/__init__.pyc'

现在,cd到上面lib正上方的目录.您看到 bin 目录了吗?你在那个垃圾箱里看到 rosdep 了吗?如果是这样,请尝试将 bin 添加到您的 $PATH.

Now, cd to the directory right above lib in the above. Do you see a bin directory? Do you see rosdep in that bin? If so try adding the bin to your $PATH.

audrey:2.7 jluc$ cd /opt/local/Library/Frameworks/Python.framework/Versions/2.7
audrey:2.7 jluc$ ls -1

输出:

Headers
Python
Resources
bin
include
lib
man
share

这篇关于pip 成功安装软件包,但未从命令行找到可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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