When you execute a script, the kernel looks for the interpreter specified in the shebang (#!
). The location of the interpreter is extracted, and then the interpreter (e.g. python3
) is launched, executing the script itself. If the interpreter binary is not found, execution fails with a No such file or directory
(ENOENT
) error (as per man 2 execve
):
ERRORS
<
... >
ENOENT The file filename or a script or ELF interpreter does not exist,
or a shared library needed
for the file or interpreter cannot be found.
You have specified #!/usr/bin/python3
in your shebang, but in the base image you use (python:3.7.2-alpine
) the python3
binary is at different location:
$ docker run - it python: 3.7 .2 - alpine sh / # which python3 / usr / local / bin / python3
To avoid such situations, shebangs in scripts usually refer not to the interpreter itself (#!/usr/bin/python3
), but to /usr/bin/env
binary, which finds and executes the interpreter:
#!/usr/bin/env python3
So i would expect that this would launch the anycodings_docker application and make it available on port anycodings_docker 6001, but instead it gives me the following anycodings_docker error:,Finally, the correct version of your anycodings_flask script would be as follows:,I'm following the micro services course on anycodings_docker testdriven.io. In this course I need to anycodings_docker deploy a Flask application with Docker. To anycodings_docker run the application I use Flask-cli, and it anycodings_docker gives me an error on start up:,And my manage.py file which will launch the anycodings_docker application:
I'm following the micro services course on anycodings_docker testdriven.io. In this course I need to anycodings_docker deploy a Flask application with Docker. To anycodings_docker run the application I use Flask-cli, and it anycodings_docker gives me an error on start up:
No such file or directory: '/usr/src/app/manage.py': '/usr/src/app/manage.py'
This is how my compose file looks like:
version: '3.7'
services:
users:
build:
context: . / services / users
dockerfile: Dockerfile - dev
volumes:
-'./services/users:/usr/src/app'
ports:
-6001: 6000
environment:
-FLASK_APP = project / __init__.py -
FLASK_ENV = development -
COMPOSE_CONVERT_WINDOWS_PATHS = 1
My docker file:
# base image FROM python: 3.7 .2 - alpine # set working directory WORKDIR / usr / src / app # add and install requirements COPY. / requirements.txt / usr / src / app / requirements.txt RUN pip install - r requirements.txt # add app COPY. / usr / src / app # i tried to give it the right rights..but it didn 't help RUN chmod + x / usr / src / app / manage.py # run server CMD python manage.py run - h 0.0 .0 .0
When you execute a script, the kernel anycodings_flask looks for the interpreter specified in anycodings_flask the shebang (#!). The location of the anycodings_flask interpreter is extracted, and then the anycodings_flask interpreter (e.g. python3) is launched, anycodings_flask executing the script itself. If the anycodings_flask interpreter binary is not found, anycodings_flask execution fails with a No such file or anycodings_flask directory (ENOENT) error (as per man 2 anycodings_flask execve):
ERRORS
<
... >
ENOENT The file filename or a script or ELF interpreter does not exist,
or a shared library needed
for the file or interpreter cannot be found.
You have specified #!/usr/bin/python3 in anycodings_flask your shebang, but in the base image you anycodings_flask use (python:3.7.2-alpine) the python3 anycodings_flask binary is at different location:
$ docker run - it python: 3.7 .2 - alpine sh / # which python3 / usr / local / bin / python3
To avoid such situations, shebangs in anycodings_flask scripts usually refer not to the anycodings_flask interpreter itself (#!/usr/bin/python3), anycodings_flask but to /usr/bin/env binary, which finds anycodings_flask and executes the interpreter:
#!/usr/bin/env python3
I also met with the same problem ...READ MORE,I am trying to run one python script to fetch dynamic IP. But it is showing me the below error., Hi@akhtar, I think there is a problem with ...READ MORE,It seems your python script is not able to find python in your system. You may have python3 installed in your system. But it is finding /usr/bin/python folder. So you can create a symlink to it.
I am trying to run one python script to fetch dynamic IP. But it is showing me the below error.
/usr/bin / env: ‘python’: No such file or directory
It seems your python script is not able to find python in your system. You may have python3 installed in your system. But it is finding /usr/bin/python folder. So you can create a symlink to it.
$ sudo ln - s / usr / bin / python3 / usr / bin / python
October 11, 2021 collectstatic, django, python No comments ,BASE_DIR is correct, checked it. Directory BASE_DIR/static/ exists and all my static files are there., [FIXED] in VS Code ImportError: cannot import name 'Mapping' from 'collections' Issue I am trying to connect to Postgress and create a folder test.db via Flask. When I ru... ,I've performed a lot of collectstatic-calls and everything worked fine, but today have this issue.
In django 1.7 collectstatic throws an exception for me:
OSError: [Errno 2] No such file or directory: '/static'
settings.py
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'fxblog',
'rest_framework',
)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, STATIC_URL.strip("/"))
STATICFILES_DIRS = (
'/static/',
'/upload/',
)
Traceback:
Traceback (most recent call last):
File "../manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 173, in handle_noargs
collected = self.collect()
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 103, in collect
for path, storage in finder.list(self.ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/finders.py", line 106, in list
for path in utils.get_files(storage, ignore_patterns):
File "/usr/local/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py", line 25, in get_files
directories, files = storage.listdir(location)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py", line 249, in listdir
for entry in os.listdir(path):
OSError: [Errno 2] No such file or directory: '/static'
Also it is good to set STATIC_ROOT to something like
STATIC_ROOT = normpath(join(BASE_DIR, 'assets'))
and STATIC_URL
STATIC_URL = '/static/'