python – any function to access pickle causes FileNotFoundError

Question:

The error:

> Traceback (most recent call last):
> File ".scriptspickle_threed_future_dataset.py", line 127, in <module>
> main(sys.argv[1:])
> File ".scriptspickle_threed_future_dataset.py", line 101, in main
> scenes_dataset = ThreedFront.from_dataset_directory(
> File "c:usersmibigdesktopatissscene_synthesisdatasetsthreed_front.py", line 169, in from_dataset_directory
> scenes = parse_threed_front_scenes(
> File "c:usersmibigdesktopatissscene_synthesisdatasetsutils.py", line 129, in parse_threed_front_scenes
> pickle.dump(scenes, open("/tmp/threed_front.pkl", "wb"))
> FileNotFoundError: [Errno 2] No such file or directory: '/tmp/threed_front.pkl'

The codes that causes the error:

if os.getenv("PATH_TO_SCENES"):
        scenes = pickle.load(open(os.getenv("PATH_TO_SCENES"), "rb"))
    else:
    scenes = sum(scenes, [])
        pickle.dump(scenes, open("tmpthreed_front.pkl", "wb"))

The code’s github source readme file shows that the script is supposed to automatically write a file in tmp/threed_front.pkl. It also mentions that I should set the created .pkl file as my PATH_TO_SCENES.

I am unable to find the /tmp directory or a threed_front.pkl file. I tried creating a /tmp folder in the environment and root directory but it still shows the same error.

According to some other stackoverflow problem from suggestions, some of them mentioned trying to code the absolute path in instead of using variables. I tried it by changing the python code itself to the a tmp folder I created, in order to fix the problem and tried to write the absolute path in, but the same error showed up. The getenv and pickle.dump functions are not the problem.

I am new to conda/python, sorry if I am not providing enough information. I am not exactly sure about what is wrong too. If possible, can I get some pointers or directions as to how to fix this problem? (Like what could be the cause of my problems) Thank you.

Asked By: kkkkkkkkkkkkkkkin

||

Answers:

So ‘tmpthreed_front.pkl’ this is wrong path because this is trying to open file at ‘C:tmpthreed_front.pkl’, which I don’t think you want.

Backslash at start of path means that it will start from your drive ‘C:’

I think what you want is ‘.tmpthreed_front.pkl’ or ‘tmpthreed_front.pkl’.

This will open file from your terminal path.

pickle.dump(scenes, open(".tmpthreed_front.pkl", "wb"))

It will do the same as:

pickle.dump(scenes, open("tmpthreed_front.pkl", "wb"))

elsely if you want to are in eg. in folder C:pythonprojectsfoo
and you want to get file from another project then you need to just type ..<project name><filename>.

.. will return folder

.... will return 2 folders

Answered By: Gren Man