Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
semiprogarlic opened this issue Mar 16, 2024 · 6 comments

Comments

@semiprogarlic
Copy link

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
Copy link

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
Copy link

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
Copy link

Thanks @frank2016ma that actually solves the issue

@codespearhead
Copy link

codespearhead commented Mar 22, 2024

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
Copy link

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

@codespearhead
Copy link

codespearhead commented May 19, 2024

@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 microsoft/vscode-remote-release#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants