以下目录中的xclip和xsel都不是

时间:2014-02-03 03:32:05

标签: python linux

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

  

其中:没有xclip(/ usr / local / bin:/ usr / bin:/ bin:/ usr / local / sbin:/ usr / sbin:/ sbin:/ home / myUser / bin)

     

其中:没有xsel(/ 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下载的转置密码。

欢迎所有建议和修改:)

2 个答案:

答案 0 :(得分:0)

根据评论,您没有安装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上,repo提供了xsel。

答案 1 :(得分:0)

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

  

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

请确保使用以下软件包,否则将不会安装上述软件包。

  

yum -y install libc.so.6

     

yum -y install libXmu.so.6

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

  

的/ usr /斌/ 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日编辑

最后我发现主要功能缺少一个下划线,所以我能用这个小修补程序运行我的程序。问题解决了。