Apify Discord Mirror

Updated last week

Error running actor FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.

At a glance
The community member is trying to run an actor and is encountering permission issues when downloading certain files. They have provided their Dockerfile and have tried various solutions, including changing the COPY command and adding a script to download the files. The community members have suggested adding a line to run the download script after installing the dependencies, and this appears to have resolved the issue for some. The summary is that the community members are collaborating to troubleshoot and find a solution to the permission error.
Useful resources
I'm trying to run my actor & it's giving this log:
Plain Text
2025-03-09T00:13:41.538Z ACTOR: Pulling Docker image of build 20IgkKFk3QAzeFbk9 from repository.
2025-03-09T00:13:42.170Z ACTOR: Creating Docker container.
2025-03-09T00:13:42.237Z ACTOR: Starting Docker container.
2025-03-09T00:13:44.148Z Downloading model definition files...
2025-03-09T00:13:44.419Z Error downloading fingerprint-network.zip: [Errno 13] Permission denied: '/usr/local/lib/python3.13/site-packages/browserforge/fingerprints/data/fingerprint-network.zip'
2025-03-09T00:13:44.430Z Downloading model definition files...
2025-03-09T00:13:44.452Z Error downloading input-network.zip: [Errno 13] Permission denied: '/usr/local/lib/python3.13/site-packages/browserforge/headers/data/input-network.zip'
...
2025-03-09T00:13:44.580Z   File "/usr/local/lib/python3.13/site-packages/browserforge/bayesian_network.py", line 288, in extract_json
2025-03-09T00:13:44.582Z     with zipfile.ZipFile(path, 'r') as zf:
2025-03-09T00:13:44.583Z          ~~~~~~~~~~~~~~~^^^^^^^^^^^
2025-03-09T00:13:44.586Z   File "/usr/local/lib/python3.13/zipfile/__init__.py", line 1367, in __init__
2025-03-09T00:13:44.588Z     self.fp = io.open(file, filemode)
2025-03-09T00:13:44.590Z               ~~~~~~~^^^^^^^^^^^^^^^^
2025-03-09T00:13:44.592Z FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.13/site-packages/browserforge/headers/data/input-network.zip'
Marked as solution
@🟢mido🟢
add this line in your Dockfile , after pip install command
Plain Text
python src/download_browserforge_files.py
View full solution
A
a
11 comments
I built this actor & could run it earlier successfully, but I got this after the last build.
Here's my Dockerfile:
Plain Text
# First, specify the base Docker image.
# You can see the Docker images from Apify at https://hub.docker.com/r/apify/.
# You can also use any other image from Docker Hub.
FROM apify/actor-python:3.13

# Second, copy just requirements.txt into the Actor image,
# since it should be the only file that affects the dependency install in the next step,
# in order to speed up the build
COPY requirements.txt ./

# Install the packages specified in requirements.txt,
# Print the installed Python version, pip version
# and all installed packages with their versions for debugging
RUN echo "Python version:" \
 && python --version \
 && echo "Pip version:" \
 && pip --version \
 && echo "Installing dependencies:" \
 && pip install -r requirements.txt \
 && echo "All installed Python packages:" \
 && pip freeze

# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick build will be really fast
# for most source file changes.
COPY . ./

# Use compileall to ensure the runnability of the Actor Python code.
RUN python3 -m compileall -q .

# Create and run as a non-root user.
RUN useradd --create-home apify && \
    chown -R apify:apify ./
USER apify

# Specify how to launch the source code of your Actor.
# By default, the "python3 -m ." command is run
CMD ["python3", "-m", "src"]

I tried changing this line in dockefile as apify AI suggested:
Plain Text
COPY . ./

with:
Plain Text
COPY --chown=apify:apify . ./

But same error. I don't understand where the real error originates & how to resolve it?
@🟢mido🟢 just advanced to level 1! Thanks for your contributions! 🎉
i met same issue
@axly just advanced to level 2! Thanks for your contributions! 🎉
@🟢mido🟢
add this line in your Dockfile , after pip install command
Plain Text
python src/download_browserforge_files.py
@axly Hi
Please where've you put download_browserforge_files.py ? I added it to my src/ but can't find it when building:
Plain Text
python: can't open file '/usr/src/app/src/download_browserforge_files.py': [Errno 2] No such file or directory

I'm running the file after copying all files & directories so it should work:
Plain Text
# Install the packages specified in requirements.txt,
# Print the installed Python version, pip version
# and all installed packages with their versions for debugging
RUN echo "Python version:" \
 && python --version \
 && echo "Pip version:" \
 && pip --version \
 && echo "Installing dependencies:" \
 && pip install -r requirements.txt \
 && echo "All installed Python packages:" \
 && pip freeze

# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick build will be really fast
# for most source file changes.
COPY . ./

# Download browserforge
RUN python src/download_browserforge_files.py
Just copy it to src folder in your project
I swear it's there 😦
anyway thank you for help I'll check it out later
Attachment
image.png
Good news: there was a typo extra 's' in this command, filename is download_browserforge_file
Bad news: still getting the same permission error after building & running:
Plain Text
Error downloading input-network.zip: [Errno 13] Permission denied: '/usr/local/lib/python3.13/site-packages/apify_fingerprint_datapoints/data/input-network.zip'

if anyone with same issue please help
you should switch to root when run the python code. and switch back to normal user at end of the dockfile
Thank you so much finally it worked!
for any one facing same issue I just had to copy files again after running download_browserforge_file.py
like that in Dockerfile:
Plain Text
# Next, copy the remaining files and directories with the source code.
# Since we do this after installing the dependencies, quick build will be really fast
# for most source file changes.
COPY . ./
# Download browserforge
RUN python src/download_browserforge_file.py
COPY . ./
Add a reply
Sign up and join the conversation on Discord