python - 以下目录中的 xclip 和 xsel 均不存在

标签 python linux

我刚刚完成对脚本的一些修改,我尝试使用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()  

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

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

欢迎所有建议和修改:)

最佳答案

根据评论,您没有安装 xclipxsel。您可以检查为他们提供了哪些软件包:

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 存储库上提供了 xsel。

关于python - 以下目录中的 xclip 和 xsel 均不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21519278/

相关文章:

python - 将 1 个常量值添加到 python 列表中的所有 sub_list

linux - 如何暂停后台进程?

c++ - 调试在嵌入式 Linux 设备上运行的 C/C++ 应用程序的内存泄漏

python - Pandas :某些列中的总和值

python - 为什么有各种 JPEG 扩展?

c++ - 为什么 QPainter 不绘制到我的 QWidget?

c - getdelim 报告的无效参数

linux - BASH Wikitables 获取硬件信息

python - 如何并行并发 HTTP 请求

Python - Mailchimp 批量 PUT 请求