Search code examples
pythonvisual-studiovisual-studio-codepathpycharm

python module current path is wrong on vs code


i used ./ to accses my current path for my python module its perfectly work with pycharm but when i try to run it on Vscode, its consider my current path as C:\user\user my module is not even in my C drive

for example i run this code :


import pathlib
varname = pathlib.Path().resolve()
print(varname)

and i got 2 diffrent outputs

in vs code i got: C:\Users\User and in pycharm its : P:\programing\wtong-path

By the way i specify the module locations in pycharm but there is no such option for vscode


Solution

  • You could try to change the current working directory on VSC by the following code:

    import os
    os.chdir('your path here')
    

    I believe this won't give any output but your path would change.