vscode 에서 보통 가상 환경 추가할 때 화면 하단의 버전 정보를 클릭해서 Create Virtual Environment 를 지정하면 생성을 하게 됩니다.
더보기
관련 그림
아래 부분 클릭
Create Virtual Environment... 선택
venv 선택
python 을 기존 오래된 버전을 삭제하고 새 버전(현재 기준 3.12 및 3.11)을 설치하고 잘 쓰다가 오랜만에 가상 환경을 추가했는데 오류가 떳습니다.
2024-07-10 10:24:36.755 [info] Running: D:\user\util\installed\python3.12\python.exe -m venv .venv
2024-07-10 10:24:38.178 [info] > .\.venv\Scripts\python.exe -I ~\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\get_output_via_markers.py ~\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\interpreterInfo.py
2024-07-10 10:24:38.178 [info] Environments refresh paths discovered: 12 milliseconds
2024-07-10 10:24:38.269 [info] Environments refresh finished (event): 104 milliseconds
2024-07-10 10:24:44.743 [info] CREATED_VENV:d:\user\src\excel_test\.venv\Scripts\python.exe
2024-07-10 10:24:44.743 [info] Creating: d:\user\src\excel_test\.venv\.gitignore
2024-07-10 10:24:44.744 [info] CREATE_VENV.UPGRADING_PIP
Running: d:\user\src\excel_test\.venv\Scripts\python.exe -m pip install --upgrade pip
2024-07-10 10:24:45.434 [info] Requirement already satisfied: pip in .\.venv\lib\site-packages (24.0)
2024-07-10 10:24:45.793 [info] Collecting pip
2024-07-10 10:24:46.024 [info] Downloading pip-24.1.2-py3-none-any.whl.metadata (3.6 kB)
2024-07-10 10:24:46.038 [info] Downloading pip-24.1.2-py3-none-any.whl (1.8 MB)
2024-07-10 10:24:46.276 [info]
2024-07-10 10:24:46.276 [info] ---------------------------------------- 1.8/1.8 MB 8.9 MB/s eta 0:00:00
2024-07-10 10:24:46.276 [info]
2024-07-10 10:24:46.318 [info] Installing collected packages: pip
2024-07-10 10:24:46.318 [info] Attempting uninstall: pip
2024-07-10 10:24:46.323 [info] Found existing installation: pip 24.0
2024-07-10 10:24:46.539 [info] Uninstalling pip-24.0:
2024-07-10 10:24:47.448 [info] ERROR: Could not install packages due to an OSError: [WinError 32] 다른 프로세스가 파일을 사용 중이기 때문에 프로세스가 액세스 할 수 없습니다: 'd:\\user\\src\\excel_test\\.venv\\lib\\site-packages\\pip\\_vendor\\msgpack'
Check the permissions.
2024-07-10 10:24:47.453 [info] WARNING: Ignoring invalid distribution ~ip (d:\user\src\excel_test\.venv\Lib\site-packages)
2024-07-10 10:24:47.470 [info] WARNING: Ignoring invalid distribution ~ip (d:\user\src\excel_test\.venv\Lib\site-packages)
2024-07-10 10:24:47.546 [info] Traceback (most recent call last):
File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\create_venv.py", line 92, in run_process
2024-07-10 10:24:47.546 [info] subprocess.run(args, cwd=os.getcwd(), check=True)
File "D:\user\util\installed\python3.12\Lib\subprocess.py", line 571, in run
2024-07-10 10:24:47.558 [info] raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['d:\\user\\src\\excel_test\\.venv\\Scripts\\python.exe', '-m', 'pip', 'install', '--upgrade', 'pip']' returned non-zero exit status 1.
2024-07-10 10:24:47.558 [info] During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\create_venv.py", line 258, in <module>
2024-07-10 10:24:47.558 [info] main(sys.argv[1:])
File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\create_venv.py", line 241, in main
2024-07-10 10:24:47.559 [info] upgrade_pip(venv_path)
File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\create_venv.py", line 130, in upgrade_pip
2024-07-10 10:24:47.559 [info] run_process(
File "c:\Users\user\.vscode-insiders\extensions\ms-python.python-2024.10.0-win32-x64\python_files\create_venv.py", line 94, in run_process
2024-07-10 10:24:47.559 [info] raise VenvError(error_message)
VenvError: CREATE_VENV.UPGRADE_PIP_FAILED
2024-07-10 10:24:47.559 [info]
2024-07-10 10:24:47.585 [error] Error while running venv creation script: CREATE_VENV.UPGRADE_PIP_FAILED
2024-07-10 10:24:47.585 [error] CREATE_VENV.UPGRADE_PIP_FAILED
뭔가 말도 안된다라고 생각해서 로그에 남겨진 pip 설치 업그레이드 명령에 있는 경로(d:\\user\\src\\excel_test\\.venv\\Scripts)로 이동해서 pip 를 실행했더니 동일한 오류 메시지를 보이며 실행이 안되었습니다.
C:\Users\user>d:
D:\> cd d:\\user\\src\\excel_test\\.venv\\Scripts
d:\user\src\excel_test\.venv\Scripts> activate.bat
(.venv) d:\user\src\excel_test\.venv\Scripts>pip
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "d:\user\src\excel_test\.venv\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip._internal.cli'
(.venv) d:\user\src\excel_test\.venv\Scripts>python -m pip install -U pip
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "d:\user\src\excel_test\.venv\Lib\site-packages\pip\__main__.py", line 22, in <module>
from pip._internal.cli.main import main as _main
ModuleNotFoundError: No module named 'pip._internal.cli'
인터넷에서는 pip 를 재설치해야 한다고 합니다. 설치 방법들이 동작을 하는게 없어서 찾아 헤매다가 간신히 하나를 찾아 기록으로 남깁니다.
근데 curl 을 쓰네요.. 윈도우에서 되나? 하고 실행해보니 잘 됩니다.. 걍 도전!!
아래 명령으로 get-pip.py 를 받아, 실행하면 됩니다.
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall
혹시 몰라서 python -m pip install -U pip 명령을 실행해보니 잘 실행됩니다.
(.venv) d:\user\src\excel_test\.venv\Scripts>curl
curl: try 'curl --help' for more information
(.venv) d:\user\src\excel_test\.venv\Scripts>curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 2224k 100 2224k 0 0 8833k 0 --:--:-- --:--:-- --:--:-- 8934k
(.venv) d:\user\src\excel_test\.venv\Scripts>python get-pip.py --force-reinstall
WARNING: Ignoring invalid distribution ~ip (d:\user\src\excel_test\.venv\Lib\site-packages)
WARNING: Ignoring invalid distribution ~ip (d:\user\src\excel_test\.venv\Lib\site-packages)
Collecting pip
Using cached pip-24.1.2-py3-none-any.whl.metadata (3.6 kB)
Collecting setuptools
Downloading setuptools-70.3.0-py3-none-any.whl.metadata (5.8 kB)
Collecting wheel
Using cached wheel-0.43.0-py3-none-any.whl.metadata (2.2 kB)
Using cached pip-24.1.2-py3-none-any.whl (1.8 MB)
Downloading setuptools-70.3.0-py3-none-any.whl (931 kB)
---------------------------------------- 931.1/931.1 kB 6.5 MB/s eta 0:00:00
Using cached wheel-0.43.0-py3-none-any.whl (65 kB)
WARNING: Ignoring invalid distribution ~ip (d:\user\src\excel_test\.venv\Lib\site-packages)
Installing collected packages: wheel, setuptools, pip
Successfully installed pip-24.1.2 setuptools-70.3.0 wheel-0.43.0
(.venv) d:\user\src\excel_test\.venv\Scripts>python -m pip install -U pip
Requirement already satisfied: pip in d:\user\src\excel_test\.venv\lib\site-packages (24.1.2)
'IT > editor & ide' 카테고리의 다른 글
[notepad++] 정규식(regex) 간단 정리 (2) | 2024.03.12 |
---|---|
[raspberry pi] 원격으로 rpi vim 설정 변경하기 (0) | 2023.06.20 |
[windows 10][vscode][python][intellisense] 동작 안하는 문제 (0) | 2022.07.22 |
[vim] 문자열 대치시 개행문자로 바꾸고 싶은 경우 (0) | 2022.03.16 |
[vim] 특정 줄, 또는 칸 지정하기 (0) | 2014.08.13 |