“<unprintable file name>” error when running pip or venv

谁说我不能喝 提交于 2020-01-24 06:01:43

问题


I have several people on my team that are running into an intermittent problem running some very basic Python commands. The following is all in Windows 10, using the Python Launcher (the py command that allows you to setup a default Python – in our case Python 3.7).

Running from a Git repo root directory pip can fail.

$ py -m pip install --upgrade pip
C:\Apps\Python37\python.exe: can't open file '<unprintable file name>': [Errno 2] No such file or directory

or setting up a virtual environment.

$ py –m venv .venv
C:\Apps\Python37\python.exe: can't open file '<unprintable file name>': [Errno 2] No such file or directory

Clearly it is finding and running Python, but then Python is unable to open some file in the middle of the process. It can't even name the file/directory. I did some searching and the '<unprintable file name>' part may be due to spaces in a folder, but that's the best I've got.

Notes and things we have tried:

  • A few people in the team have never seen this, with the same tools installed (VS Code as IDE, etc.)
  • It is a mix of Python 3.7.5 and 3.7.6, I think all 64-bit (Note, I original had 3.7.4 with the same setup and have never seen this)
  • Moving Python out of the "C:\Program Files" and the user directory doesn't seem to help
  • It is definitely intermittent for all the people that ran into it, sometimes running a few other commands will work, then the bad one suddenly works as well
  • We generally use Git Bash as the terminal
  • Exactly how Python37 and Python37/Scripts shows up in the path varies (whether at beginning/end and User or System path).

I can't find any pattern. We did remove old Python folders from the path, removed all Python paths from the User Path, and moved the current Python 3.7 folders to the top of the system path for one person and it may have fixed the problem.

Question:

Any idea what this is? How do you even dig further into this to figure out what is failing?

Update

This may only be a problem until pip is updated (either in the system install location and/or in any new virtual environment created). It might be going away after success is intermittently achieved.

I never personally had this issue on my PC with 3.7.4, nor by updating to 3.7.6 in-place as a test, it may be a defect related to version 3.7.5 or 3.7.6 along with the specific version of pip that comes with those packages. However, once pip is successfully updated to 19.3.1, it seems to go away.

My current guesses:

  • It has something to do with specific versions of Python 3.7 (3.7.5 or 3.7.6) and Pip 19.x interacting with each other poorly, missing a dependency, or something similar.
  • It is related to spotty internet or proxy connections to the internet that are causing partial downloads and pip is not detecting the issue (our proxy can take a while to establish the initial connection with some SSO and security stuff going on in the background).

来源:https://stackoverflow.com/questions/59778734/unprintable-file-name-error-when-running-pip-or-venv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!