系統找不到指定的檔案python

WINDOWS 平台许多软件的安装和打开,都会发生 系统找不到指定文件的情况

下面列举种 系统找不到指定文件 解决方法,一种是文件所在的目录太长,一种是文件缺失。

目录路径太长

1

如下图,这个文件找不到,是因为目录路径太长,WINDOWS识别不了这么长的目录,

首先,这个目录上级目录已经是WINDOWS的临时缓存目录,然后是压缩包的一个缓存目录再套下一个压缩包的缓存目录,目录路径太长,造成WINDOWS根本无法识别,所以提示 系统找不到指定文件

系統找不到指定的檔案python

2

将压缩包中的压缩包解压出来,再打开其中的文件,这样就不会提示 错误了

系統找不到指定的檔案python

系統找不到指定的檔案python

3

改变系统的临时缓存 目录,将临时缓存目录

右键 我的电脑-- 高级 -- 环境变量

系統找不到指定的檔案python

4

改变 Administrator 的用户变量 中 双击TEMP ,TMP目录路径,把路径改短一点,如图:

可以改相同的目录,也可以是不同的目录,但是不要用根目录,用根目录,会造成出现很多的临时缓存文件,很乱。

系统环境变量不要轻易修改,切记

这样在解压嵌套压缩包的时候,路径就不会变的特别长,错误提示就解决了。

系統找不到指定的檔案python

系統找不到指定的檔案python

系統找不到指定的檔案python

5

最后一种识别了不了的问题,是 中文目录乱码识别不了,解决的方法

可以把安装的目录改为 桌面,或者把中文目录全部变成 简单的拼音

桌面 这个 中文目录,识别出来的是 Desktop ,其实也是英语目录

END

文件缺失

1

如图,以下两种情况再排除之前目录太长问题之后,就是文件缺失的问题,缺少某种插件,文件被安全软件屏蔽,文件已不存在。

系統找不到指定的檔案python

系統找不到指定的檔案python

2

查看缺失文件的名称,可以使用百度搜索,查看一下是不是某个插件,如果是插件,可以下载单独安装

系統找不到指定的檔案python

3

安全软件屏蔽引起系统找不到文件的错误,有的软件,比如类似私服登录器,有一定的潜在病毒性,被各种安全软件自动屏蔽,删除,这就要看用户是不是确定没有病毒危害特性

系統找不到指定的檔案python

4

文件已不存在,如图

所以可以要确定,这个文件是不是存在与目标目录。

系統找不到指定的檔案python

END

注意事项

本经验仅适用于 WINDOWS 窗口提示 系统找不到指定文件,对网页和CMD下提示另外对待

经验内容仅供参考,如果您需解决具体问题(尤其法律、医学等领域),建议您详细咨询相关领域专业人士。

举报作者声明:本篇经验系本人依照真实经历原创,未经许可,谢绝转载。

展开阅读全部

(WechatPCAPI) D:\Ariya\pyproject\WechatPCAPI\src>pyinstaller -F auto-reply.py

119 INFO: PyInstaller: 4.2

119 INFO: Python: 3.7.3

......

4836 INFO: Building EXE from EXE-00.toc completed successfully.

虽然成功了,但是打开的时候显示:

解决办法:用-D命令打包,然后把lib放在根目录

(WechatPCAPI) D:\Ariya\pyproject\WechatPCAPI\src>pyinstaller -D auto-reply.py

60 INFO: PyInstaller: 4.2

60 INFO: Python: 3.7.3

......

3422 INFO: Building COLLECT COLLECT-00.toc

3583 INFO: Building COLLECT COLLECT-00.toc completed successfully.

完美运行!

File "I:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py",
根据提示找到lib中的subprocess.py文件,CTRL+f查找class Popen模块,再将这个模块中的
init函数中的shell = False 改成shell = True

来源:https://blog.csdn.net/weixin_44853744/article/details/102680386

  File "I:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\site-packages\selenium\webdriver\common\service.py", line 72, in start
    self.process = subprocess.Popen(cmd, env=self.env,
  File "I:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "I:\Users\Administrator\AppData\Local\Programs\Python\Python38\lib\subprocess.py", line 1307, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

路径不对 导致FileNotFoundError: [WinError 2] 系统找不到指定的文件, 问题解决办法

执行python + selenium 代码

from selenium import webdriver

driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe")
driver.get("http://www.baidu.com")

报错:FileNotFoundError: [WinError 2] 系统找不到指定的文件。

D:\pycode\test\venv\Scripts\python.exe D:/pycode/test/Testa/test01.py
Traceback (most recent call last):
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\common\service.py", line 74, in start
stdout=self.log_file, stderr=self.log_file)
File "C:\Python36-32\Lib\subprocess.py", line 709, in __init__
restore_signals, start_new_session)
File "C:\Python36-32\Lib\subprocess.py", line 997, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] 系统找不到指定的文件。

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:/pycode/test/Testa/test01.py", line 3, in <module>
driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe")
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\chrome\webdriver.py", line 68, in __init__
self.service.start()
File "D:\pycode\test\venv\lib\site-packages\selenium\webdriver\common\service.py", line 81, in start
os.path.basename(self.path), self.start_error_message)
selenium.common.exceptions.WebDriverException: Message: 'chromedriver.exe' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home


Process finished with exit code 1

原因是指定chromedriver路径错误中用了 window路径正斜杠,正确的是用反斜杠

正确的代码

from selenium import webdriver

#driver = webdriver.Chrome("D:\AutoConf\bin\chromedriver.exe")  #错误的路径 使用正斜杠
driver = webdriver.Chrome("D:/AutoConf/bin/chromedriver.exe") #正确的路径 使用反斜杠

driver.get("http://www.baidu.com")

 

posted @ 2017-12-21 11:18  testway  阅读(58499)  评论(1)  编辑  收藏  举报