skallfass / fastapi_serviceutils

Utils for fastapi based services.
MIT License
34 stars 3 forks source link

ERROR InstallationError: Invalid requirement: 'app/main.py' #1

Closed phyxavier closed 5 years ago

phyxavier commented 5 years ago

Bootstrapped example app with following results

dephell inspect venv

results in:

{
  "activate": "/Users/<devcomp>/.local/share/dephell/venvs/<my_app>-IrrL/main/bin/activate.fish",
  "bin": "/Users/<devcomp>/.local/share/dephell/venvs/<my_app>-IrrL/main/bin",
  "exists": true,
  "lib": "/Users/<devcomp>/.local/share/dephell/venvs/<my_app>-IrrL/main/lib/python3.7/site-packages",
  "lib_size": "9.87Mb",
  "project": "/Users/<devcomp>/<Apps Dir>/<my_app>",
  "python": "/Users/<devcomp>/.local/share/dephell/venvs/<my_app>-IrrL/main/bin/python",
  "venv": "/Users/<devcomp>/.local/share/dephell/venvs/<my_app>-IrrL/main"
}

issue is as follows:

dephell venv run app/main.py
WARNING executable is not found in venv, trying to install... (executable=app/main.py)
ERROR InstallationError: Invalid requirement: 'app/main.py' (from line 1 of /var/folders/mr/3ctw8jvj4jdfk_sznlwnhv7m0000gn/T/tmphv2x_qlu)
Hint: It looks like a path. File 'app/main.py' does not exist. 
skallfass commented 5 years ago

Does this error also occur if you run

dephell venv run python app/main.py

or if you run the following?

dephell venv shell
python app/main.py

What is the content of the folder where you try to run the command?

phyxavier commented 5 years ago

output from above:

main ❯ dephell venv run python app/main.py
INFO running... (command=['python', 'app/main.py'])
Traceback (most recent call last):
  File "app/main.py", line 10, in <module>
    from app import __version__
ImportError: cannot import name '__version__' from 'app' (/Users/<user>/.local/share/dephell/venvs/<my_app>-IrrL/main/lib/python3.7/site-packages/app/__init__.py)
ERROR command failed (code=1)
skallfass commented 5 years ago

Does the file app/__init__.py inside your project have the variable __version__ defined?

phyxavier commented 5 years ago

it is as follows:

"""Example to demonstrate fastapi-usage."""
__version__ = '0.1.0'
skallfass commented 5 years ago

Ok, then perhaps try to either run: PYTHONPATH=. dephell venv run python app/main.py or to first activate the shell with dephell venv shell and the run PYTHONPATH=. python app/main.py perhaps the pythonpath is not set correctly. Does this help?

phyxavier commented 5 years ago

it worked! Thanks.

Used this:

env PYTHONPATH=. python app/main.py
skallfass commented 5 years ago

Great :) Thanks that you try this package.