- 官网选择版本后,下载
embeddable zip file
- 打开 PowerShell,下载并执行脚本
.\install-python.ps1 python-3.9.0-embed-amd64.zip C:\Users\User\Python
- 如无权限则需设置
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
- 在环境变量PATH中添加
C:\Users\User\Python
和C:\Users\User\Python\Scripts
- 下载
https://bootstrap.pypa.io/get-pip.py
并执行python get-pip.py
安装 pip pip install virtualenv
安装 virtualenv
-
-
Save awsvpc/b4e30abb4b2d952116ce1839405d4441 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
[Parameter(Mandatory=$true)][string]$zip, | |
[string]$dir = "$HOME\Python" | |
) | |
if (Test-Path $dir) { | |
Remove-Item $dir | |
} | |
New-Item -Path $dir -ItemType Directory -Force | |
$7z = "$Env:Programfiles\7-Zip\7z.exe" | |
if (Test-Path $7z) { | |
Start-Process -NoNewWindow -Wait -PassThru -FilePath $7z -ArgumentList x,$zip,"-o$dir" | |
} else { | |
Expand-Archive -Path $zip -DestinationPath $dir -Force | |
} | |
New-Item -Path $dir -ItemType Directory -Force -Name Lib | |
New-Item -Path $dir -ItemType Directory -Force -Name DLLs | |
New-Item -Path $dir -ItemType Directory -Force -Name Scripts | |
$zip = Get-ChildItem -File -Path $dir\*.zip | |
if (Test-Path $7z) { | |
Start-Process -NoNewWindow -Wait -PassThru -FilePath $7z -ArgumentList x,$zip,"-o$dir\Lib" | |
} else { | |
Expand-Archive -Path $zip -DestinationPath $dir\Lib -Force | |
} | |
Get-ChildItem -File -Path $dir\*.dll,$dir\*.pyd,$dir\*.cat -Exclude vcruntime*.dll,python*.dll | Move-Item -Destination $dir\DLLs | |
Get-ChildItem -File -Path $dir\*._pth,$dir\*.zip | Remove-Item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment