I am running the following code :
import os, configparser
config = configparser.ConfigParser()
config = config.read(r'C:\Users\ms\Desktop\3815_ticket\pconfig.txt')
portfolio_path=config['Data']['portfolio']
os.rename(portfolio_path,'bloop')
I obtain the following error :
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\ms\\Desktop\\\\data_lin\\portfolio.xlsx' -> 'bloop'
I read some old posts about this error, hence I modified it as follow :
with config.read(r'C:\Users\ms\Desktop\3815_ticket\pconfig.txt') as x :
portfolio_path=x['Data']['portfolio']
os.rename(portfolio_path,'bloop')
But now I obtain
AttributeError: __enter__
I then tried to avoid a with
block; I copied my file paths stored in pconfig.txt and then deleted the configparser object, but I still obtain the [WinError 32]
error.
Any help would be appreciated !