PermissionError: [WinError 32] Another program is using this file and the process cannot be accessed. : 'C: \ Users \ video \ AppData \ Local \ Temp \ tmpfipzk8ma '-- solve the problem, win32error0n87
Learning python + selenium always encounters various problems
The Code is as follows:
From selenium import webdriver
Browser = webdriver. PhantomJS () # initialize the browser. Set the phantomjs path in Win and leave it blank in linux.
Url = 'HTTP: // www.zhidaow.com '# Set the access path
Browser. get (url) # Open the webpage
Title = browser. find_elements_by_xpath ('// h2') # Use xpath to obtain elements
For t in title: # traverse the output
Print (t. text) # output text
Print (t. get_attribute ('class') # output attribute values
Browser. quit ()
An error is reported after running:
File "C: \ Users \ video \ AppData \ Roaming \ Python \ Python34 \ site-packages \ selenium \ webdriver \ common \ service. py ", line 151, in _ del __
File "C: \ Users \ video \ AppData \ Roaming \ Python \ Python34 \ site-packages \ selenium \ webdriver \ common \ service. py", line 127, in stop
File "C: \ Users \ video \ AppData \ Roaming \ Python \ Python34 \ site-packages \ selenium \ webdriver \ phantomjs \ service. py", line 68, in send_remote_shutdown_command
PermissionError: [WinError 32] Another program is using this file and the process cannot be accessed. : 'C: \ Users \ video \ AppData \ Local \ Temp \ tmpfipzk8ma'
Solution: (I use pycharm)
Edit the file C: \ Users \ video \ AppData \ Roaming \ Python \ Python34 \ site-packages \ selenium \ webdriver \ phantomjs \ service. py
Find:
def send_remote_shutdown_command(self):
if self._cookie_temp_file:
os.remove(self._cookie_temp_file)
Modify as follows:
def send_remote_shutdown_command(self):
try:
if self._cookie_temp_file:
os.remove(self._cookie_temp_file)
except:
pass