Reputation: 49
Hi I've recently been trying to import and use a wheel (downloaded from pypi) in PyScript. This wheel corresponds to the biopython library. However, I have been unable to see any results in this regard. Does anyone know why my code is not working?
<html>
<head>
<link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
<script defer src="https://pyscript.net/alpha/pyscript.js"></script>
</head>
<body>
</body>
<py-env>
- './static/wheels/biopython-1.79-cp37-cp37m-win_amd64.whl'
</py-env>
<py-script>
from Bio.Seq import Seq
my_seq = Seq("AGTACACTGGT")
print(my_seq)
</py-script>
</html>
Below I show the error capture in my BRAVE browser console.
Uncaught (in promise) PythonError: Traceback (most recent call last):
File "/lib/python3.10/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 234, in __step
result = coro.throw(exc)
File "/lib/python3.10/site-packages/micropip/_micropip.py", line 183, in install
transaction = await self.gather_requirements(requirements, ctx, keep_going)
File "/lib/python3.10/site-packages/micropip/_micropip.py", line 173, in gather_requirements
await gather(*requirement_promises)
File "/lib/python3.10/asyncio/futures.py", line 284, in __await__
yield self # This tells Task to wait for completion.
File "/lib/python3.10/asyncio/tasks.py", line 304, in __wakeup
future.result()
File "/lib/python3.10/asyncio/futures.py", line 201, in result
raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 232, in __step
result = coro.send(None)
File "/lib/python3.10/site-packages/micropip/_micropip.py", line 243, in add_requirement
raise ValueError(f"'{wheel['filename']}' is not a pure Python 3 wheel")
ValueError: 'biopython-1.79-cp37-cp37m-win_amd64.whl' is not a pure Python 3 wheel
at new_error (pyodide.asm.js:14:238191)
at pyodide.asm.wasm:0xedbcb
at pyodide.asm.wasm:0xf1a0e
at method_call_trampoline (pyodide.asm.js:14:238105)
at pyodide.asm.wasm:0x134c2c
at pyodide.asm.wasm:0x217a84
at pyodide.asm.wasm:0x174a14
at pyodide.asm.wasm:0x135149
at pyodide.asm.wasm:0x135243
at pyodide.asm.wasm:0x1352e6
at pyodide.asm.wasm:0x1fff83
at pyodide.asm.wasm:0x1f98b5
at pyodide.asm.wasm:0x135329
at pyodide.asm.wasm:0x201f1b
at pyodide.asm.wasm:0x1ff9ff
at pyodide.asm.wasm:0x1f98b5
at pyodide.asm.wasm:0x135329
at pyodide.asm.wasm:0xf16d8
at Object.Module.callPyObjectKwargs (pyproxy.gen.ts:360:23)
at Object.Module.callPyObject (pyproxy.gen.ts:384:17)
at wrapper (pyodide.asm.js:14:205222)
Upvotes: 0
Views: 967
Reputation: 49
I found a way to do it but without the ".whl". The problem is that biopython is not a pure Python wheel, in this sense you have to notify the pyodide team so that they add it. The pyodide team only adds popular projects like biopython. I still feel like we still need a tool that gives us freedom like pip in the case of PyScript.
Solution below, We just need to import "-Bio"
<py-env>
- Bio
</py-env>
<py-script>
from Bio.Seq import Seq
my_seq = Seq("AGTACACTGGT")
print(my_seq)
print(my_seq.find("ACT"))
</py-script>
Upvotes: 2