tiangolo / full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
MIT License
24.79k stars 4.2k forks source link

Running task 1 of 1: python .copier/update_dotenv.py /bin/sh: 1: python: not found #733

Open semiprogarlic opened 4 months ago

semiprogarlic commented 4 months ago

I have python3 installed and have configured an alias python="python3" in my .bash_aliases file, so both python and python3 cmdlets are available.

DESKTOP-0U5S399:~$ python --version Python 3.8.10

DESKTOP-0U5S399:~$ python3 --version Python 3.8.10

However, copier is unable to find the python module in /bin/sh. Can we update the copier.yml file to use python3 .copier/update_dotenv.py instead of python .copier/update_dotenv.py?

> Running task 1 of 1: python .copier/update_dotenv.py /bin/sh: 1: python: not found Traceback (most recent call last): File "/home/dathuku/.local/bin/copier", line 8, in <module> sys.exit(copier_app_run()) File "/home/dathuku/.local/lib/python3.8/site-packages/plumbum/cli/application.py", line 638, in run inst, retcode = subapp.run(argv, exit=False) File "/home/dathuku/.local/lib/python3.8/site-packages/plumbum/cli/application.py", line 633, in run retcode = inst.main(*tailargs) File "/home/dathuku/.local/lib/python3.8/site-packages/decorator.py", line 232, in fun return caller(func, *(extras + args), **kw) File "/home/dathuku/.local/lib/python3.8/site-packages/copier/cli.py", line 71, in handle_exceptions return method(*args, **kwargs) File "/home/dathuku/.local/lib/python3.8/site-packages/copier/cli.py", line 270, in main worker.run_copy() File "/home/dathuku/.local/lib/python3.8/site-packages/copier/main.py", line 205, in __exit__ raise value File "/home/dathuku/.local/lib/python3.8/site-packages/copier/cli.py", line 270, in main worker.run_copy() File "/home/dathuku/.local/lib/python3.8/site-packages/copier/main.py", line 759, in run_copy self._execute_tasks(self.template.tasks) File "/home/dathuku/.local/lib/python3.8/site-packages/copier/main.py", line 284, in _execute_tasks subprocess.run(task_cmd, shell=use_shell, check=True, env=local.env) File "/usr/lib/python3.8/subprocess.py", line 516, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command 'python .copier/update_dotenv.py' returned non-zero exit status 127

chapimenge3 commented 4 months ago

Same Issue with My Window WSL

  > Running task 1 of 1: python .copier/update_dotenv.py
/bin/sh: 1: python: not found
Traceback (most recent call last):
  File "/home/username/.local/bin/copier", line 8, in <module>
    sys.exit(copier_app_run())
  File "/home/username/.local/lib/python3.10/site-packages/plumbum/cli/application.py", line 638, in run
    inst, retcode = subapp.run(argv, exit=False)
  File "/home/username/.local/lib/python3.10/site-packages/plumbum/cli/application.py", line 633, in run
    retcode = inst.main(*tailargs)
  File "/home/username/.local/lib/python3.10/site-packages/decorator.py", line 232, in fun
    return caller(func, *(extras + args), **kw)
  File "/home/username/.local/lib/python3.10/site-packages/copier/cli.py", line 71, in handle_exceptions
    return method(*args, **kwargs)
  File "/home/username/.local/lib/python3.10/site-packages/copier/cli.py", line 263, in main
    with self._worker(
  File "/home/username/.local/lib/python3.10/site-packages/copier/main.py", line 205, in __exit__
    raise value
  File "/home/username/.local/lib/python3.10/site-packages/copier/cli.py", line 270, in main
    worker.run_copy()
  File "/home/username/.local/lib/python3.10/site-packages/copier/main.py", line 759, in run_copy
    self._execute_tasks(self.template.tasks)
  File "/home/username/.local/lib/python3.10/site-packages/copier/main.py", line 284, in _execute_tasks
    subprocess.run(task_cmd, shell=use_shell, check=True, env=local.env)
  File "/usr/lib/python3.10/subprocess.py", line 526, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command 'python .copier/update_dotenv.py' returned non-zero exit status 127.
frank2016ma commented 4 months ago

I got the same Issue with both my armbian and debian12. I have set alias python="python3" in ~/.bashrc file, but it didn't work. Maybe it's not a project issue, but a Python issue. Finally, I tried apt install python-is-python3, and then it worked

chapimenge3 commented 4 months ago

Thanks @frank2016ma that actually solves the issue

codespearhead commented 4 months ago

It's highly advisable you use virtual environments. It'll not only solve said problem, but it'll also save you the headaches that will arise from dependency management, such as conflicting global package installations.

This issue can now be closed in my opinion.

cblberlin commented 2 months ago

i got the same issue on MacOS, i configured alias python="python3" in my .zshrc, but it just don't work

codespearhead commented 2 months ago

@cblberlin Figuring out whether the Python command will be available under python or python3, or if it is available at all especially after a fresh installation of Python, is something extremely inconsistent for a variety of reasons, ranging from what shell you're using (BASH, ZSH, etc.) to how the terminal session is being created (VSCode GUI https://github.com/microsoft/vscode-remote-release/issues/83, System Launcher, etc.) to the command interpreter you're using (BASH, ZSH, etc.).

Hence, trying to come up with a one-size-fits-all solution is just not feasible.

If I were you I'd save myself the headache and rollback the modifications you made to ~/.zshrc to try to fix it, then figure out under which command Python 3 is available by runing python -V andpython3 -V (recreate the terminal session by closing it and opening it again in case neither work after having just installed Python 3), so you can use the correct command to create and activate the virtual environment, as pointed out in my previous answer, and call it a day.

DennisKretz commented 1 month ago

In the file copier.yml search for "_tasks:" then change the line python .copier/update_dotenv.py to python3 .copier/update_dotenv.py

And if you are wondering why it is still not working then it is because you are using copier with the remote repo, and not your local.

Just fork the repo, change the line, and then use copier like this -> copier copy path_to_your_fork project-name --trust

cblberlin commented 1 month ago

thx man, i will try it