Usr bin env python r no such file or directory windows

I am trying to deploy the hyperlegder sawtooth in my windows local machine from the below repository 'https://github.com/hyperledger/education'. When I start the application using Docker, then ...

I am trying to deploy the hyperlegder sawtooth in my windows local machine from the below repository ‘https://github.com/hyperledger/education’.

When I start the application using Docker, then I am getting an error for the tunachain-tp as below

tunachain-tp        | /usr/bin/env: 'python3r': No such file or directory

I have tried to solve the problem in the below ways

  1. Installed python and configured the path variable
  2. Uninstalled python

But, unfortunately none of the solution is worked out for me.

How to solve this problem?

Matthieu Brucher's user avatar

asked Oct 26, 2018 at 8:59

Subburaj's user avatar

1

Your issue is not with Python but with your file encoding.

It is a Windows file (end of line rn) but the file should be Unix (end of line n). To fix this on Windows, you can do this in Notepad++ -> end of line Unix. You can also use cygwin (or Linux inside the docker container actually) with dos2unix.

answered Oct 26, 2018 at 9:03

Matthieu Brucher's user avatar

Matthieu BrucherMatthieu Brucher

21.2k7 gold badges37 silver badges59 bronze badges

1

The above is probably your problem.
Also verify Python version 3 is installed with….

python3 --version

On the command line.

answered Oct 27, 2018 at 5:43

Dan Anderson's user avatar

Dan AndersonDan Anderson

2,2551 gold badge8 silver badges20 bronze badges

1

The root of the problem is that spaces in shebangs are interpreted as supplying additional arguments to an executable, so C:Program FilesPythonpython.exe gets seen as C:Program given FilesPythonpython.exe as an argument.

The best solution for this, because Windows LOVES spaces in the $HOME directory and Program Files and other places even though it can really break things in cmd.exe and Powershell and other tools, is:

Install Python to C:Python and add the C:Python folder where python.exe lives and the Scripts directory that lives inside it to your PATH environment variable at the system or user level.

If you need Python 2.7.x and 3.x to co-exist, install them into C:Python27 and C:Python36 and C:Python37 and rename the python.exe to python2.exe, python36.exe, python37.exe, etc and add each of those folders and their Scripts folders into the PATH. You may want to determine which of the Python 3 versions you want to be the «default» and also make a copy in that folder as python3.exe to handle any scripts that use !#/usr/bin/env python3.

If your user home directory has a space in it, you may also experience issues if you use the pip install --user somepackage syntax. The --user defaults to your home directory, and the space will trip up things in this case as well. The workaround is described here but boils down to exporting PYTHONUSERBASE to your environment.

export PYTHONUSERBASE=/myappenv
pip install --user SomePackage

or in Windows (Powershell):

$env:PYTHONUSERBASE='C:PythonPkgs'
pip install --user SomePackage

I am trying to install Gitlab Development Kit on Windows Ubuntu Bash.

$python3 output

Python 3.5.2 (default, Nov 17 2016, 17:05:23)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

$python output

The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

When I try to do this:

sudo apt-get install build-essential 
./configure 
make -j4 # adjust according to your available CPU capacity 
sudo make install

This is the output after ./configure

$ ./configure
/usr/bin/env: ‘python’: No such file or directory

$ python --version 

The program 'python' can be found in the following packages:
 * python-minimal
 * python3
Try: sudo apt install <selected package>

$which -a python

no output

How can I solve this? I am new to Ubuntu.

TRiG's user avatar

TRiG

1,9102 gold badges18 silver badges39 bronze badges

asked Aug 4, 2017 at 8:29

mertselimb's user avatar

5

For Ubuntu 20.04 you can use following package to python command. And it is python 3.

sudo apt install python-is-python3

Description of the package:

Description: symlinks /usr/bin/python to python3

 Starting with the Debian 11 (bullseye) and Ubuntu 20.04 LTS (focal)
 releases, all python packages use explicit python3 or python2
 interpreter and do not use unversioned /usr/bin/python at all. Some
 third-party code is now predominantly python3 based, yet may use
 /usr/bin/python.
 .
 This is a convenience package which ships a symlink to point
 the /usr/bin/python interpreter at the current default python3. It may
 improve compatibility with other modern systems, whilst breaking some
 obsolete or 3rd-party software.

Pablo Bianchi's user avatar

answered May 3, 2020 at 1:28

Dinuka Thilanga's user avatar

2

Problem scenario:

/usr/bin/env: ‘python’: No such file or directory

Possible Solution #1

If Python 3 is not installed, install it: apt-get install python3

Possible Solution #2

If Python 3 has been installed, run these commands: whereis python3

Then we create a symlink to it: sudo ln -s /usr/bin/python3 /usr/bin/python

answered May 5, 2020 at 7:44

Francesco Mantovani's user avatar

3

I had the same problem after installing Ubuntu 18.04 and trying to run some python scripts.

I tried:

sudo apt-get install python2.7-minimal

but I still got the same error. I solved it by:

sudo apt install python-minimal

Stephen Rauch's user avatar

answered Aug 24, 2018 at 4:15

nwaweru's user avatar

nwawerunwaweru

2912 silver badges7 bronze badges

4

You do seem to have python3 installed, but it isn’t called python and anyway the script you want to run (configure) requires python 2. So:

  1. Install python2

    sudo apt-get install python2.7-minimal
    
  2. Run it again

    ./configure
    

If that fails again, call it with python2 explicitly:

/usr/bin/python2.7 configure

Wassim Dhif's user avatar

answered Aug 4, 2017 at 9:27

terdon's user avatar

terdonterdon

96.2k15 gold badges192 silver badges289 bronze badges

Yet Another Solution:

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 10
update-alternatives: using /usr/bin/python3 to provide /usr/bin/python (python) in auto mode

Tested & verified on my 20.04LTS system. See man update-alternatives for details. And, «No — it’s not necessary to have Python2 installed for this to work.»

answered Nov 30, 2020 at 0:00

deWalker's user avatar

deWalkerdeWalker

3714 silver badges8 bronze badges

I had the same problem, It got solved by linking python to python2.7 with the following commands

cd /usr/bin
sudo mv python python.bak
sudo ln -s /usr/bin/python2.7 /usr/bin/python

Félicien's user avatar

Félicien

1,1231 gold badge10 silver badges18 bronze badges

answered Apr 9, 2018 at 15:15

Ranjan Ravee's user avatar

1

If you don’t want to mess up with your system configuration, you can just replace the first line of your configure file

  1. Open it with your favorite text editor
  2. Replace #!/usr/bin/env python with #!/usr/bin/env python3
  3. Save and keep playing!

answered Dec 30, 2020 at 2:56

Joshua Salazar's user avatar

Joshua SalazarJoshua Salazar

3771 gold badge3 silver badges14 bronze badges

Just for reference… I had a similar issue — running a python script from the docker container failed with «No such file or directory», my solution was to force Unix style line endings on the checkout of the code and in the IDE (as it was bind-mounted from the Windows host to the container).

answered Feb 9, 2019 at 18:49

Rots's user avatar

RotsRots

1112 bronze badges

Check the spelling in the first line. Trailing spaces have been known to prevent the shell from locating the shell…

«#!/usr/bin/env tclsh «

The training space confused bash.

Eliah Kagan's user avatar

Eliah Kagan

115k53 gold badges310 silver badges482 bronze badges

answered Jun 4, 2020 at 22:03

Richard's user avatar

Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

nakalkucing

I know there are several questions and answers about this already, but i still can’t fix my problem. :P

In the video Kenneth types: chmod +x diary.py and ./diary.py

I followed this and received back the following error: /usr/bin/env: ‘python3r’: No such file or directory

If anyone can tell me how to run this I would really appreciate it. Thanks in advance! :)

Here’s my code:

#!/usr/bin/env python3

import datetime

from peewee import *

db = SqliteDatabase('diary.db')


class Entry(Model):
    content = TextField()
    timestamp = DateTimeField(default=datetime.datetime.now)

    class Meta:
        database = db


def initialize():
    """Create the database and the table if they dont exist."""
    db.connect()
    db.create_tables([Entry], safe=True)


def menu_loop():
    """Show the menu"""


def add_entry():
    """Add an entry."""


def view_entries():
    """View previous entries."""


def delete_entry(entry):
    """Delete an entry."""


if __name__ == '__main__':
    initialize()
    menu_loop()

2 Answers

Phu Tran February 5, 2019 3:12am

Hi, could you post the full code? I tried to edit the code in 30 minutes and still get «No such file or directory»

thumb

Recently, when attempting to use a youtube-dl tool in the Terminal app, I saw an error message saying /usr/bin/env: ‘python’: No such file or directory. In this tutorial, you will learn how to fix the error that leads to this error message.

What causes this error

In my case, the below error appeared when attempting to run the youtube-dl tool in the Terminal app on my MacBook with Ubuntu 20.04 LTS.

$ youtube-dl http://youtube.com/...
/usr/bin/env: ‘python’: No such file or directory

The error message above is self explanatory. It saying that the system cannot find the python binary file.

We can run the following simple command to determine that the python (it’s actually named python3, where 3 is the version number) package is installed in the system:

python3: /usr/bin/python3 /usr/bin/python3.8 /usr/lib/python3 /usr/lib/python3.8 /etc/python3 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8 /usr/share/python3 /usr/share/man/man1/python3.1.gz

In my case, I see that the python3 package is already installed. Therefore, something is wrong with the system paths, so the system cannot find its binary file.

If in your case there is no output at all, then you do not have python3 installed.

Now we know what caused this error.

How to solve it

Once we know what is causing this error message to appear, we can use it to solve the problem. It is a really easy process. To solve this problem, we need to install the python3 package, if it is not already installed, and create a symlink to it. Now, step by step guide.


Launch your terminal app. As a terminal app, I use the Terminal app that is shipped with Ubuntu, but you can use any other terminal app.


In the terminal, type the following commands and press the Enter key to install the python3 package, if it is not already installed.

Note! Ubuntu 20.04 and other versions of Debian Linux ship with Python 3 pre-installed.

sudo apt update
sudo apt install python3

When prompted, type your computer administrator password and press the Enter key.

Note! Terminal doesn’t show any characters as you type your password. This is normal Terminal behaviour.


Now, type the following command and press the Enter key to create a symlink from “python” to “python3”.

sudo ln -s /usr/bin/python3 /usr/bin/python

Conclusion

That’s it, you’re done. Now the /usr/bin/env: ‘python’: No such file or directory error should be gone. So simple isn’t it?

If you are having trouble fixing this problem with the instructions above, but are being able to solve this problem with any another method please describe it in the comment section below. Thanks!

I hope this article has helped you learn how to fix the /usr/bin/env: ‘python’: No such file or directory error. If this article has helped you then please leave a comment :smiley:

Thanks for reading!

Понравилась статья? Поделить с друзьями:
  • Usosvc что это за служба windows 10
  • Usoshared что это за папка windows 10
  • Usoprivate что это за папка windows 10 можно ли удалить
  • Uso что это за папка windows 10
  • Uso скачать бесплатно для windows 10