【问题标题】:Neither xclip nor xsel in the following directory以下目录中既不是 xclip 也不是 xsel
【发布时间】:2014-02-03 03:32:05
【问题描述】:

我刚刚完成了对脚本的一些修改,我尝试在终端上使用 Python 执行它,但终端提示如下:

which: no xclip in (/usr/local/bin: /usr/bin: /bin: /usr/local/sbin: /usr/sbin:/sbin:/home/myUser/bin)

which: no xsel in (/usr/local/bin: /usr/bin: /bin: /usr/local/sbin: /usr/sbin:/sbin:/home/myUser/bin)

这是我正在尝试执行的以下脚本:

import random, sys, CipherEncryptionP

def main():
    random.seed(42)
        for i in range(20):
        message       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*random.randint(4,40)
        message       = list(message)
        random.shuffle(message)
        print('Test #%s: "%s..."' % (i+1, message[:50]))
        for key in range(1,len(message)):
            encrypted = CipherEncryptionP.encryptMessage(message,key)
            print('Transposition cipher test passed. ')

if __name__=='__main__':
    main()

最后,这是您从上面运行代码所需的 CipherEncryptionP 脚本。

import pyperclip

def main():
    message        = raw_input("Give me your message: ")
    keyValue       = int(raw_input("Give a numeric value: "))
    ciphertext     = encryptMessage(message,keyValue)
    print(ciphertext + '|')
    pyperclip.copy(ciphertext)

def encryptMessage(message,keyValue):
    ciphertext=['']*keyValue
    for column in range(keyValue):
        pointer= column
        while pointer < len(message):
            ciphertext[column]+=message[pointer]
            pointer+=keyValue
    return ''.join(ciphertext)

if __name__== '__main_':
    main()  

我正在运行内核版本为 2.6.32-431.1.2.el6.x86_64 的 Scientific Linux 6.2,Python 版本为 2.6.6。您可以从以下页面下载 pyperclip:http://invpy.com/pyperclip.py

第一个代码用于测试第二个代码,它是我从http://inventwithpython.com/hacking/chapter10.html下载的转置密码。

欢迎所有建议和修改:)

【问题讨论】:

  • 您是否安装了xclipxsel
  • which xclip, which xsel。如果没有安装,请安装它们。
  • 它抛出以下内容: /usr/bin/which: no xclip in /usr/local/sbin: /usr/local/bin:/sbin:/usr/sbin:/sbin:/home /myUser/bin

标签: python linux


【解决方案1】:

根据您没有安装xclipxsel 的cmets。您可以查看为他们提供的软件包:

yum whatprovides xclip

输出:xclip .... 对 xsel 执行相同操作。

同时安装它们:

sudo yum install xclip xsel

获取可执行文件的完整路径:

whereis -b xclip

which xclip

如果您没有提供 xsel/xclip 的存储库,则需要设置一个。这是一个示例:http://www.cyberciti.biz/faq/fedora-sl-centos-redhat6-enable-epel-repo/。在我的 CentOS Epel repo 上提供了 xsel。

【讨论】:

  • 找不到匹配项。
  • 感谢您的建议。我已经在安装您的存储库,并且能够解决我的问题。
【解决方案2】:

我在我的计算机中找到了以下安装 xclip 和 xsel 的软件包。

rpm -ivh xclip-0.12-1.el6.rf.i686.rpm

一定要yum下面的包,否则上面的包不会被安装。

yum -y 安装 libc.so.6

yum -y 安装 libXmu.so.6

但是,我的程序仍然没有被python执行,因为它出现了以下地址:

/usr/bin/xclip

2 月 3 日编辑

最后我的程序成功了,我发现问题出在第一个代码上。

import random, sys, CipherEncryptionP
random.seed(42)
    for i in range(20):
    message       = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'*random.randint(4,40)
    message       = list(message)
    random.shuffle(message)
    print('Test #%s: "%s..."' % (i+1, message[:50]))
    for key in range(1,len(message)):
        encrypted = CipherEncryptionP.encryptMessage(message,key)
    print('Transposition cipher test passed. ')

我不知道我一开始的主要功能有什么问题,但这个新修复肯定解决了我的问题。

2 月 3 日编辑

最后我发现 main 函数缺少下划线,所以我能够通过这个小修复运行我的程序。问题解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-08
    • 2021-07-05
    • 2014-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多