简体   繁体   English

查找工具/脚本/子目录

[英]Finding Tools/scripts/ subdirectory

有人知道我在Ubuntu上哪里可以找到文件吗?

On my machine it's in: 在我的机器上,它位于:

/usr/share/doc/python2.7/examples/Tools/scripts/diff.py

However, it'll vary a little depending on your distrib and how up to date you are. 但是,这取决于您的分配和最新情况。 But there's a really handy little tool called 'locate' that you can use to quickly find stuff on your machine. 但是有一个非常方便的小工具叫做“定位”,您可以使用它来快速查找机器上的东西。

locate diff.py | grep Tools

Gives me 给我

/usr/share/doc/python2.7/examples/Tools/scripts/diff.py
/usr/share/doc/python2.7/examples/Tools/scripts/ndiff.py
/usr/share/doc/python3.1/examples/Tools/scripts/diff.py
/usr/share/doc/python3.1/examples/Tools/scripts/ndiff.py

As I have two versions of Python installed. 由于我安装了两个版本的Python。 I put it through grep, as sometimes locate can match quite a lot. 我通过grep进行了说明,因为有时locate可以匹配很多。

If you're sure that you have a file on your machine, but locate isn't finding it, you might need to update your database, which is done with the 'updatedb' command, as root. 如果确定您的计算机上有文件,但找不到文件,则可能需要以root用户身份使用“ updatedb”命令来更新数据库。 So, just run 因此,只需运行

sudo updatedb

and get a coffee (or two if you have a slow machine/very full drive) and then try again. 然后喝杯咖啡(如果机器速度慢/驱动器已满,则喝两杯),然后重试。

This command 这个命令

  $ locate "Tools/scripts/diff.py"

will find the location of the file if it's installed. 如果已安装文件,它将找到文件的位置。 This depends on the database generated regularly by the updatedb command (this usually runs as a cron job, but can also be invoked manually) 这取决于由updatedb命令定期生成的数据库(通常作为cron作业运行,但也可以手动调用)

FWIW, I just checked my Ubuntu installation (10.04LTS) and didn't find it. FWIW,我刚刚检查了Ubuntu安装(10.04LTS),却没有找到它。 Perhaps only Python versions 2.7+ have this (the default version that came with this install is still v2.6.5) 也许只有2.7+的Python版本具有此功能(此安装随附的默认版本仍为v2.6.5)。

I needed to know this for a different environment, namely Linux running an Amazon Machine Image (AMI). 我需要针对其他环境(即运行Amazon Machine Image(AMI)的Linux)知道这一点。 I installed Python 3.5 via "yum" but couldn't find the Tools/scripts directory using find/locate, etc., or any other "yum" package which included it. 我通过“ yum”安装了Python 3.5,但无法使用find / locate等或任何其他包含它的“ yum”包来找到Tools / scripts目录。

So in the end I cloned the python source tree mirror: 所以最后我克隆了python源代码树镜像:

git clone https://github.com/python-git/python python

This downloads the Tools/scripts folder which I then moved to some standard location. 这将下载“工具/脚本”文件夹,然后将其移至某个标准位置。 I needed the "2to3" program from "scripts" and this worked. 我需要“脚本”中的“ 2to3”程序,并且可以正常工作。 There is also a "clone or download" link at that URL where the package can be downloaded in the usual way if git is not available. 在该URL上还有一个“克隆或下载”链接,如果git不可用,则可以按通常方式下载该软件包。

I couldn't find an easy way to install the Tools/scripts via "yum" on AMI Linux, which would still be my preference. 我找不到在AMI Linux上通过“ yum”安装工具/脚本的简便方法,这仍然是我的偏爱。

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

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