Python3.8 venv 返回退出状态 101 [英] Python3.8 venv returned exit status 101

查看:154
本文介绍了Python3.8 venv 返回退出状态 101的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了类似的帖子,主要与 venv 上的 linux 相关,但工作有问题.

此后它工作正常:

PS C:\Utilities\PythonBase\Python38>.\python -m venv c:\temp\venv-py38PS C:\Utilities\PythonBase\Python38>

当然,您必须检查并修复您一直在使用的任何 venv,但如果您的情况与我相同,它们无论如何都不会工作.

I found similar posts, mostly related to linux on venv having an issue with working. python 3.8 venv missing activate command However, I am confused on how to solve it on windows, and what is happening.

I installed python3.8 from downloading it on pythons website. Then I follow the 3.8 documentation https://docs.python.org/3/library/venv.html which shows:

python3 -m venv /path/to/new/virtual/environment

I do this but then get the following error:

Error: Command '['E:\\py_envs\\hf4\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

When I use: python -m venv --without-pip hf4

and then hf4\Scripts\activate

It works for activation. What I don't understand is that I can then run pip and it is there during the activated environment. It seems a maybe related issue, is that anything I have installed on my system python is also available. For example, in the activated session:

(hf4) E:\py_envs>where pip
C:\Users\local user\AppData\Local\Programs\Python\Python38\Scripts\pip.exe

One question is naturally how to fix this, the other is that I would appreciate an explanation as to what is happening to better understand it. Does it search first for the active environment, and if it can't find it, defaults to a system version?

解决方案

I had the same problem (with both Python 3.7 and 3.8), I believe it was due to a Windows update when I enrolled in the Windows Insiders program, but that could have just been a coincidence.

PS C:\Users\Your Name\AppData\Local\Programs\Python\Python38> ./python -m venv c:\TEMP\py38-venv
Error: Command '['c:\\TEMP\\py38-venv\\Scripts\\python.exe', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 101.

This worked around the problem in my case:

  • Uninstall Python.
  • Install with the Custom option.
  • Use the "Install for all users".

After this it worked fine:

PS C:\Utilities\PythonBase\Python38> .\python -m venv c:\temp\venv-py38
PS C:\Utilities\PythonBase\Python38>

Of course you'll have to go through and fix any venvs you've been using, but if you're in the same situation as me they won't have been working anyway.

这篇关于Python3.8 venv 返回退出状态 101的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆