Problem with import

118 views
Skip to first unread message

sakshi chourasia

unread,
Nov 23, 2015, 11:44:38 PM11/23/15
to brython
Hello All,

I facing problem while importing the module in Brython. I am importing the "Pyperclip" module as below -

<body onload="brython(1)">
    <script type="text/python">
        from browser import doc   
        import pyperclip

        def copy_to_clipboard(event):
            logging.info('Copied to clipboard')
            pyperclip.copy(document["copy_to_clipboard_button"].value)
            spam = pyperclip.paste()

        document['id_copy_text_box'].bind('click', copy_to_clipboard)
     </script>
</body>

Below is the error which is coming up -

2015-11-24 10:08:16,066 - INFO - 127.0.0.1 - - [24/Nov/2015 10:08:16] "POST /respose_CR_superuser HTTP/1.1" 200 -
2015-11-24 10:08:16,262 - INFO - 127.0.0.1 - - [24/Nov/2015 10:08:16] "GET /pyperclip.py?v=3 HTTP/1.1" 404 -
2015-11-24 10:08:16,267 - INFO - 127.0.0.1 - - [24/Nov/2015 10:08:16] "GET /pyperclip/__init__.py?v=4 HTTP/1.1" 404 -
2015-11-24 10:08:16,272 - INFO - 127.0.0.1 - - [24/Nov/2015 10:08:16] "GET /static/Lib/site-packages/pyperclip.py?v=5 HTTP/1.1" 404 -
2015-11-24 10:08:16,276 - INFO - 127.0.0.1 - - [24/Nov/2015 10:08:16] "GET /static/Lib/site-packages/pyperclip/__init__.py?v=6 HTTP/1.1" 404 -

I have seen the previous thread on import issues on this group but could not solve this issue. It will be great if someone can help me in solving this out.

Thank you,

Regards,
Sakshi

Pierre Quentel

unread,
Nov 24, 2015, 2:45:08 AM11/24/15
to brython
Hi Sakshi,

Brython searches the module to import in a number of places : the standard distribution (there is no trace in the console because the program searches in a list of modules in script stdlib_paths.js) , then the directory where your HTML page stands, then the folder site-packages (you see the traces of Ajax requests for these locations in the console).

Are you sure that the pyperclip module is in one of these places ?

- Pierre

Kiko

unread,
Nov 24, 2015, 3:03:54 AM11/24/15
to bry...@googlegroups.com
The problem with the import seems related with brython not finding the lib.

But pyperclip will not work with Brython. It uses subprocess and pygtk/pyQt to do the job and Brython can't use subprocess (you can only access the system in a very limited way) or the gui libs (made mainly in C/C++).

I created an example to do the trick here:
http://jsfiddle.net/0z04Ldo9/3/

Let me know if this helps.

Best

sakshi chourasia

unread,
Nov 24, 2015, 4:39:56 AM11/24/15
to brython
Thanks Pierre!

sakshi chourasia

unread,
Nov 24, 2015, 4:42:01 AM11/24/15
to brython
Thanks kiko it really worked for me in Chrome browser. In Firefox it is not working. I think Firefox has some issues with document.execCommand("copy") command.

Kiko

unread,
Nov 24, 2015, 4:55:28 AM11/24/15
to bry...@googlegroups.com
I think I didn't sent the latest version:
http://jsfiddle.net/0z04Ldo9/5/

I tested it on FF and it is working on dev and 'regular' versions.
44.0a2 (2015-11-22) (dev edition)
42.0

--
You received this message because you are subscribed to the Google Groups "brython" group.
To unsubscribe from this group and stop receiving emails from it, send an email to brython+u...@googlegroups.com.
To post to this group, send email to bry...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/brython/34f5e0ff-85a8-4dd9-b85d-6b3a80dbb198%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages