python os.chdir() Windows Error 2

Calvin Spealman cspealma at redhat.com
Mon Apr 1 11:58:45 EDT 2019


What are you actually trying to do?

os.chdir() simply changes the current working directory of your process. It
doesn't read any data or "import" or really have any affect on its own. The
current directory is the directory you ran the script from in the first
place, which is where files will be opened from. os.chdir() changes that
directory, affecting future files you access with open(), but doesn't have
a direct effect. Multiple chdir() calls in a row would simply be
meaningless.

On Mon, Apr 1, 2019 at 11:45 AM <grossmudda at gmail.com> wrote:

> Hey guys,
>
> I´ve got a problem importing a file with os.chdir. I´ve done a lot of
> research but still I can´t fix it. For any suggestions I would be so
> thankful!
>
> This is what I´ve tried so far:
>
> import os
> import numpy as np
> import matplotlib.pyplot as plt
>
>
> os.chdir('C:\Users\Ayla\Documents\Uni\Master_Umweltingenieurwesen\Study_Project\kerschbaum_input')
>
> os.chdir('C:\\Users\Ayla\Documents\Uni\Master_Umweltingenieurwesen\Study_Project\kerschbaum_input')
>
> os.chdir('C:\\Users\\Ayla\\Documents\\Uni\\Master_Umweltingenieurwesen\\Study_Project\\kerschbaum_input')
>
> os.chdir('C:/Users/Ayla/Documents/Uni/Master_Umweltingenieurwesen/Study_Project/kerschbaum_input')
>
> os.chdir('C://Users/Ayla/Documents/Uni/Master_Umweltingenieurwesen/Study_Project/kerschbaum_input')
>
> os.chdir('C://Users//Ayla//Documents//Uni/vMaster_Umweltingenieurwesen//Study_Project//kerschbaum_input')
>
> and each of these with [r'C:..'], " instead of ', and \\?\c instead of C.
> I also added the path (in advanced system settings) of the folder.
>
> Best regards
> Ayla
> --
> https://mail.python.org/mailman/listinfo/python-list
>


-- 

CALVIN SPEALMAN

SENIOR QUALITY ENGINEER

cspealma at redhat.com  M: +1.336.210.5107
<https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>


More information about the Python-list mailing list