PermissionError: [Errno 13] Permission denied in Django

2024/11/16 22:37:20

I have encountered a very strange problem.

I'm working with django, I create a directory on server, and try to save pickle file into it, this way:

with open(path, 'wb') as output: pickle.dump(obj, output, pickle.HIGHEST_PROTOCOL)

And get:

PermissionError: [Errno 13] Permission denied

I tried to give all permissions to this directory, this way:

os.chmod(save_full_path, stat.S_IWOTH | stat.S_IWUSR | stat.S_IWGRP)

but this didn't help.

Although directory seems to have all permissions(0o777), I still get this error.

By the way, I have no problems with saving uploaded files to this directory.

I'm very new to django, I would really appreciate if someone explained me what am I doing wrong.

Answer

It seems like i have figured out this myself. Found this question, and did excactly what is written there.

Permission denied when trying to write to file from a view

But I still don't know what was the problem in my case :(

https://en.xdnf.cn/q/71618.html

Related Q&A

Evaluating Jacobian at specific points using sympy

I am trying to evaluate the Jacobian at (x,y)=(0,0) but unable to do so. import sympy as sp from sympy import * import numpy as np x,y=sp.symbols(x,y, real=True) J = Function(J)(x,y) f1=-y f2=x - 3*y*(…

PyAudio cannot find any output devices

When I run:import pyaudio pa = pyaudio.PyAudio() pa.get_default_output_device_info()I get:IOError: No Default Output Device AvailableWhen I say:pa.get_device_count()It returns 0L.And of course if I lis…

How do I write a Hybrid Property that depends on a column in children relationship?

Lets say I have two tables (using SQLAlchemy) for parents and children:class Child(Base):__tablename__ = Childid = Column(Integer, primary_key=True) is_boy = Column(Boolean, default=False)parent_id = C…

Python insert a line break in a string after character X

What is the python syntax to insert a line break after every occurrence of character "X" ? This below gave me a list object which has no split attribute error for myItem in myList.split…

How to use properly Tensorflow Dataset with batch?

I am new to Tensorflow and deep learning, and I am struggling with the Dataset class. I tried a lot of things and I can’t find a good solution. What I am trying I have a large amount of images (500k+)…

How to handle a huge stream of JSON dictionaries?

I have a file that contains a stream of JSON dictionaries like this:{"menu": "a"}{"c": []}{"d": [3, 2]}{"e": "}"}It also includes nested dict…

datatype for handling big numbers in pyspark

I am using spark with python.After uploading a csv file,I needed to parse a column in a csv file which has numbers that are 22 digits long. For parsing that column I used LongType() . I used map() func…

Multi processing code repeatedly runs

So I wish to create a process using the python multiprocessing module, I want it be part of a larger script. (I also want a lot of other things from it but right now I will settle for this)I copied the…

Why use os.setsid() in Python?

I know os.setsid() is to change the process(forked) group id to itself, but why we need it?I can see some answer from Google is: To keep the child process running while the parent process exit.But acc…

How to apply different aggregation functions to same column by using pandas Groupby

It is clear when doingdata.groupby([A,B]).mean()We get something multiindex by level A and B and one column with the mean of each grouphow could I have the count(), std() simultaneously ?so result loo…