solara icon indicating copy to clipboard operation
solara copied to clipboard

"solara create portal solara-test-portal" not working out-of-the box

Open rd-andreas-lay opened this issue 2 years ago • 4 comments

Just following the "As a package" section from https://solara.dev/docs/howto/multipage I ran into a few issues which are related to the working directory:

  • The relative imports don't work: ImportError: attempted relative import with no known parent package
  • Changing all imports to absolute imports (import solara_test_portal...) didn't not work immediately either
  • export PYTHONPATH=PATH/TO/solara-test-portal finally fixed the imports

Another unrelated problem I ran into:

  • Problems with VAEX on the subpages: ImportError: PyO3 modules may only be initialized once per interpreter process
  • Not sure what causes the issue, I currently cannot reproduce it.

Also the app needs to be run with solara run solara_test_portal.pages instead of solara run solara_test_portal as stated in the docs. However the command line output is correct, I just guess the documentation is out-of-date here.

I ran the example with Python 3.9.

rd-andreas-lay avatar Jun 02 '23 09:06 rd-andreas-lay

Hi Andreas,

Thank you for reporting! Did you do the pip install command? The relative import should not be a problem using solara run solara_test_portal.pages The run command was fixed in #111, but I just merged this, so it's not on the documentation site yet. I think it's best we remove the vaex dependency from this example, although I also don't know why you saw that issue.

Regards,

Maarten

maartenbreddels avatar Jun 02 '23 09:06 maartenbreddels

Hi Maarten,

my mistake, I intuitively used the project folder as the working directory.

I still had to load Vaex as requirements manually though. And Vaex seems to break the hot reloading feature, that's not optimal for "playing around" (PyO3 modules may only be initialized once per interpreter process).

On an off note: Nice work! It's definitely fun to use and has potential!

layandreas avatar Jun 03 '23 11:06 layandreas

I'm experiencing the ImportError: PyO3 modules may only be initialized once per interpreter process as well. The hot-reload in combination with pydantic causes this issue in my case.

koenvo avatar Dec 14 '23 11:12 koenvo

@koenvo are you on an older version of solara?

maartenbreddels avatar Dec 18 '23 12:12 maartenbreddels

I re-discovered that the ImportError occurs when one forgets the .pages in solara run mydemo.pages. This is definitely a gotcha when using solara.

vaex seems uninstallable with contemporary python envs e.g. 3.11. This is damaging perceptions: a sample portal demo should work without friction. I know, "should" is easier to say than resource it...

For the record, a repro test:

# from a pyenv python shim version 3.11:
mkdir -p ~/.venvs/
cd ~/.venvs/
python -m venv solara-dbg
source ./solara-dbg/bin/activate
which python # check
python -m pip install --upgrade pip
pip install solara

pip freeze | grep solara :

  • solara==1.39.0
  • solara-server==1.39.0
  • solara-ui==1.39.0
# vaex is a hefty dep that is required by the generated portal example, but `pip install vaex` at least for recent versions of python leads to:
# ERROR: Could not build wheels for vaex-core, which is required to install pyproject.toml-based projects
mkdir -p $HOME/tmp/showcase/
cd $HOME/tmp/showcase/

solara create portal demo
cd demo/
pip install -e .
cd $HOME/tmp/showcase/

solara run demo # leads to ImportError: attempted relative import with no known parent package

solara run demo.pages # works, modulo the lack of "vaex"

jmp75 avatar Sep 29 '24 08:09 jmp75