从19.0.1更新点:FileNotFoundError

时间:2019-04-12 23:29:33

标签: python-3.x pip

当我在终端中执行命令<?xml version="1.0"?> <package> <job id="default" filename="file_exists.wsf"> <script language="jscript"> <![CDATA[ // <beg-block> // - caption: demo file existence check in wsh jscript // rectype: rrmicro004 // dmid: "uu446mussi0driv" // date: "2019-04-12" // tags: file,path,exists // notes: | // * seealso ;; https://stackoverflow.com/questions/38000929/check-to-see-if-file-exists-and-then-execute-code // <end-block> // regionbeg_:uu310host: function.init// function ost_fileExists(sFileSpec){ var fso = new ActiveXObject("Scripting.FileSystemObject"); var vout; if (fso.FileExists(sFileSpec)){ vout = true; }else{ vout = false; } // return(vout); } // regionend_:uu310host// // regionbeg_:: vars.init// var str_currdir = new ActiveXObject("WScript.Shell").CurrentDirectory.replace(/\\/g, '/'); str_currfile = 'file_exists.wsf'; var mytest; // regionend_:// // regionbeg_:: vars.populate// str_fullpath = [str_currdir,'/',str_currfile].join(''); str_fakepath = [str_currdir,'/','fake_noexisto.txt'].join(''); // regionend_:// // regionbeg_:: show result// mytest = ost_fileExists(str_fullpath); if(mytest){ WScript.Echo(str_fullpath +' '+"Really exist!!!"); } mytest = ost_fileExists(str_fakepath); if(!mytest){ WScript.Echo(str_fakepath +' '+"Does not exist!!!"); } // regionend_:// ]]> </script> </job> </package> 时,控制台将返回以下错误:

pip3 install pip

如果我测试Requirement already satisfied: pip in ./Library/Python/3.7/lib/python/site-packages (19.0.1) No metadata found in ./Library/Python/3.7/lib/python/site-packages Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/me/Library/Python/3.7/lib/python/site-packages/pip-19.0.1.dist-info/METADATA' ,在这种情况下,我有一个很大的障碍:

pip3 install -U pip

但是,通过Collecting pip Using cached https://files.pythonhosted.org/packages/d8/f3/413bab4ff08e1fc4828dfc59996d721917df8e8583ea85385d51125dceff/pip-19.0.3-py2.py3-none-any.whl Error checking for conflicts. Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2897, in _dep_map return self.__dep_map File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__ raise AttributeError(attr) AttributeError: _DistInfoDistribution__dep_map During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2888, in _parsed_pkg_info return self._pkg_info File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2691, in __getattr__ raise AttributeError(attr) AttributeError: _pkg_info During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 503, in _warn_about_conflicts package_set, _dep_info = check_install_conflicts(to_install) File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/check.py", line 108, in check_install_conflicts package_set, _ = create_package_set_from_installed() File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/check.py", line 47, in create_package_set_from_installed package_set[name] = PackageDetails(dist.version, dist.requires()) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2635, in requires dm = self._dep_map File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2899, in _dep_map self.__dep_map = self._compute_dependencies() File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2908, in _compute_dependencies for req in self._parsed_pkg_info.get_all('Requires-Dist') or []: File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2890, in _parsed_pkg_info metadata = self.get_metadata(self.PKG_INFO) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1410, in get_metadata value = self._get(self._fn(self.egg_info, name)) File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1522, in _get with open(path, 'rb') as stream: FileNotFoundError: [Errno 2] No such file or directory: '/Users/me/Library/Python/3.7/lib/python/site-packages/pip-19.0.1.dist-info/METADATA' Installing collected packages: pip Found existing installation: pip 19.0.1 Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/me/Library/Python/3.7/lib/python/site-packages/pip-19.0.1.dist-info/RECORD' 给出的版本是19.0.3,但是在pip3 -V命令的输出中pip软件包仍标记为19.0.1。我使用Python 3.7.2,该软件通过Mac(MacOS 10.14.4)上的HomeBrew安装。

此错误很常见,最后一行甚至通过pip出现在每个软件包安装中,因此我不知道我应该修复它还是忽略它。因为我在其他计算机/服务器上没有此错误。...

1 个答案:

答案 0 :(得分:0)

我终于找到了解决该问题的方法(感谢GitHub上的pip职员^^),通过完全删除Mac的任何python文件/文件夹,无论它们在哪里(使用find命令,终奌站)。然后,当我确定python不再存在时,我使用brew再次下载了它,现在一切正常。

我希望这会对某些人有同样的问题有所帮助!