Using custom wheels from PyPI repository

Hello,

is it possible to install Python wheel packages from an internal PyPI repository in Anaconda Code? I keep getting this error, when adding the URL to the *.whl file:

An error occurred when loading package dependencies. Please try a different installation method, version, or package.

The package has no dependencies on other packages. I can install and use the Wheel locally via PyPI without any issues. Do I need to transform the package to the Conda package format and host it via Anaconda Server?

Thank you

Loading a Python wheel from a URL should work fine with the standard wheel format.

Is it a pure Python wheel? Anaconda Code runs with pyodide, so it can only load pure Python wheels or wheels compiled for wasm32.

Yes it’s a pure python wheel.

I’ve tried the following:

  • installing via pip and using the package locally
  • moved the package to a public accessible web server
  • make sure CORS headers are correctly set
  • to load and use it via pyodide

Still I get “Unable to load package: …” in Anaconda Code when trying to add the package.

Loading a custom wheel is done via micropip.install() under the hood.

Are all of its dependencies pure Python wheels and/or available in the pre-built pyodide packages?

Thank you very much for your efforts.
Yes all it’s dependencies are pure Python wheels. I only import “phonenumbers” from PyPi. This is my test script for Pyodide.

<!doctype html>
<html>
  <head>
      <script src="https://cdn.jsdelivr.net/pyodide/v0.26.4/full/pyodide.js"></script>
  </head>
  <body>
    Pyodide test page <br>
    Open your browser console to see Pyodide output
    <script type="text/javascript">
      async function main(){
        let pyodide = await loadPyodide();

        await pyodide.loadPackage("micropip");

        const micropip = pyodide.pyimport("micropip");
        await micropip.install('phonenumbers');

        await pyodide.loadPackage('https://.../pulp/content/mplus/phonenumberparser-0.1.4-py3-none-any.whl')
        await micropip.install('phonenumberparser')


        console.log(pyodide.runPython(`
from phonenumberparser import PhoneNumberParser

parser = PhoneNumberParser()

print(parser.parse_phone_number("+41176123456789", "", 7, "DE"))
        `));

      }
      main();
    </script>
  </body>
</html>

Output is, as expected:

Loading micropip, packaging
pyodide.asm.js:10 Loaded micropip, packaging
pyodide.asm.js:10 Loading phonenumberparser
pyodide.asm.js:10 Loaded phonenumberparser
pyodide.asm.js:10 0176123456789

Are you able to view the debug console for the add-in? Click on the left-arrow icon in the upper-right corner, then choose Attach Debugger (this is for Windows Desktop version of Excel). It will bring up the browser devtools and hopefully show more of the underlying error.

1 Like

Thank you for pointing me in the right direction. I was able to figure out that it was a CORS header problem. It looks like packages are cached for a while, since I was unable to see changes to the header directly.