reflex-dev / reflex

🕸️ Web apps in pure Python 🐍
https://reflex.dev
Apache License 2.0
18.21k stars 1.01k forks source link

`pc run` fails on WSL2 #79

Closed matt-grain closed 1 year ago

matt-grain commented 1 year ago

Hi,

OS: Ubuntu on WSL2 on Win10 Env: virtualenv with pynecone installed NodeJS 16.18.1 Python 3.8.10

I just tried pynecone (pc init and pc run) and I have this error:

(.venv) matt@wsl2:~/projects/git/pynecone$ pc init
[21:03:20] Initialize the app directory.                                                                                                                                                                 pc.py:31
           Initializing the web directory.                                                                                                                                                               pc.py:47
           Finished Initializing: pynecone                                                                                                                                                               pc.py:51
(.venv) matt@wsl2:~/projects/git/pynecone$ pc run
───────────────────────────────────────────────────────────────────────────────────────────── Starting Pynecone App ─────────────────────────────────────────────────────────────────────────────────────────────
Traceback (most recent call last):
  File "/home/matt/projects/git/pynecone/.venv/bin/pc", line 8, in <module>
    sys.exit(main())
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/typer/main.py", line 214, in __call__
    return get_command(self)(*args, **kwargs)
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/typer/main.py", line 532, in wrapper
    return callback(**use_params)  # type: ignore
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/pynecone/pc.py", line 68, in run
    app = utils.get_app()
  File "/home/matt/projects/git/pynecone/.venv/lib/python3.8/site-packages/pynecone/utils.py", line 314, in get_app
    app = __import__(module, fromlist=(constants.APP_VAR,))
ModuleNotFoundError: No module named 'pynecone.pynecone'
pip freeze
anyio==3.6.2
async-timeout==4.0.2
certifi==2022.12.7
charset-normalizer==2.1.1
click==8.1.3
commonmark==0.9.1
fastapi==0.88.0
greenlet==2.0.1
gunicorn==20.1.0
h11==0.14.0
idna==3.4
plotly==5.11.0
pydantic==1.10.2
Pygments==2.13.0
pynecone-io==0.1.8
redis==4.4.0
requests==2.28.1
rich==12.6.0
sniffio==1.3.0
SQLAlchemy==1.4.41
sqlalchemy2-stubs==0.0.2a29
sqlmodel==0.0.8
starlette==0.22.0
tenacity==8.1.0
typer==0.4.2
typing-extensions==4.4.0
urllib3==1.26.13
uvicorn==0.20.0

Any idea

matt-grain commented 1 year ago

ok, a subdirectory is needed....

picklelo commented 1 year ago

Hey! I think the issue is that you named your project pynecone. This makes the imports get confused - try naming it something else.

This has been a common issue actually, I'll make a warning in the next version to catch this.

matt-grain commented 1 year ago

ah ah good point :D Thanks !

matt-grain commented 1 year ago

Thanks works well now from WSL!

picklelo commented 1 year ago

Oh, how did you resolve the host issue, I'm curious

Glad to hear its working though!

FHU-yezi commented 1 year ago

Oh, how did you resolve the host issue, I'm curious

Glad to hear its working though!

What host issue? WSL will automaticlly let the virtual machine use host network, it behaviors just like host network in Docker, I think.

So type http://localhost:3000 and it just work.

matt-grain commented 1 year ago

Nah, not sure what happened (some firewall issue.. thanks McAfee), it works using the WSL eth0 IP address (http://172....:3000)

@FHU-yezi thanks, I did not know WSL localhost was directly available to windows! Thanks :D