groovy -v JAVA_HOME is set to an invalid directory

window 中

C:\>groovy -v

ERROR: JAVA_HOME is set to an invalid directory: C:\Java\jdk1.8.0
Please set the JAVA_HOME variable in your environment
to match the location of your Java installation.


我想应该是groovy 的一个bug

进入
当我们执行 groovy -v 的时候 实际上执行的 是groovy 安装目录下
C:\Java\groovy-2.4.10\bin\groovy.bat

而 groovy.bat 调用 startGroovy.bat
groovy.bat -->
      startGroovy.bat




错误的地方



显示错误原因
修改后查看错误
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | find /I /C "%JAVA_HOME%" >2
C:\>groovy -v
A required privilege is not held by the client.

后来采用管理员执行 虽然没有上面的  权限问题错,但是还是找不到 %JAVA_HOME%

所以我怀疑 groovy 开发人员
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | find /I /C "%JAVA_HOME%" >nul 这个命令逻辑有问题,造成根本就没有搜索到 %JAVA_HOME%
造成了 errorlevel =1

如果只是想判断 %JAVA_HOME%  是否存在的 话 可以直接用
if exist "%JAVA_HOME%" (echo ok) else (echo err)

最后说说解决办法吧 
修改 
%COMMAND_COM% /C DIR "%JAVA_HOME%" 2>&1 | find /I /C "%JAVA_HOME%" >2
为
%COMMAND_COM% /C DIR "%JAVA_HOME%" >nul 


再次运行
C:\Users\bin>groovy -v
Groovy Version: 2.4.10 JVM: 1.8.0_121 Vendor: Oracle Corporation OS: Windows 7
  • 大小: 20.8 KB
  • 大小: 23.5 KB
Started by user sl Running as SYSTEM Building in workspace /var/jenkins_home/workspace/sl-express-gitflow-web [WS-CLEANUP] Deleting project workspace... [WS-CLEANUP] Deferred wipeout is used... [WS-CLEANUP] Done The recommended git tool is: NONE using credential 81a93e16-3a6b-474b-8727-1293bde49842 Cloning the remote Git repository Cloning repository http://git.sl-express.com/sl/sl-express-gitflow-web.git > /usr/bin/git init /var/jenkins_home/workspace/sl-express-gitflow-web # timeout=10 Fetching upstream changes from http://git.sl-express.com/sl/sl-express-gitflow-web.git > /usr/bin/git --version # timeout=10 > git --version # 'git version 2.30.2' using GIT_ASKPASS to set credentials gogs账号 > /usr/bin/git fetch --tags --force --progress -- http://git.sl-express.com/sl/sl-express-gitflow-web.git +refs/heads/*:refs/remotes/origin/* # timeout=10 > /usr/bin/git config remote.origin.url http://git.sl-express.com/sl/sl-express-gitflow-web.git # timeout=10 > /usr/bin/git config --add remote.origin.fetch +refs/heads/*:refs/remotes/origin/* # timeout=10 Avoid second fetch > /usr/bin/git rev-parse refs/remotes/origin/develop^{commit} # timeout=10 Checking out Revision 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f (refs/remotes/origin/develop) > /usr/bin/git config core.sparsecheckout # timeout=10 > /usr/bin/git checkout -f 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f # timeout=10 Commit message: "实现相乘的接口" > /usr/bin/git rev-list --no-walk 46c2028eb5f59801b8baca4d73fa5acbbbb33d2f # timeout=10 [SSH] script: chmod a+rw /var/run/docker.sock [SSH] executing... [SSH] completed [SSH] exit-status: 0 [sl-express-gitflow-web] $ /maven/bin/mvn -s /maven/conf/settings.xml -gs /maven/conf/settings.xml clean package -Dmaven.test.skip=true -U [INFO] Scanning for projects... [INFO] [INFO] -----------< com.sl-express.gitflow:sl-express-gitflow-web >------------ [INFO] Building sl-express-gitflow-web 1.0-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ sl-express-gitflow-web --- [INFO] [INFO] --- spring-boot-maven-plugin:2.6.6:build-info (default) @ sl-express-gitflow-web --- [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ sl-express-gitflow-web --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 3 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ sl-express-gitflow-web --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 2 source files to /var/jenkins_home/workspace/sl-express-gitflow-web/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ sl-express-gitflow-web --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ sl-express-gitflow-web --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ sl-express-gitflow-web --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ sl-express-gitflow-web --- [INFO] Building jar: /var/jenkins_home/workspace/sl-express-gitflow-web/target/sl-express-gitflow-web-1.0-SNAPSHOT.jar [INFO] [INFO] --- spring-boot-maven-plugin:2.6.6:repackage (default) @ sl-express-gitflow-web --- [INFO] Replacing main artifact with repackaged archive [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.899 s [INFO] Finished at: 2025-06-29T23:35:04+08:00 [INFO] ------------------------------------------------------------------------ [sl-express-gitflow-web] $ /bin/bash /tmp/jenkins10798732479328880887.sh chmod: cannot access 'target/-1.0-SNAPSHOT.jar': No such file or directory Docker version 20.10.17, build 100c701 ---------停止容器()--------- "docker stop" requires at least 1 argument. See 'docker stop --help'. Usage: docker stop [OPTIONS] CONTAINER [CONTAINER...] Stop one or more running containers ---------删除容器()--------- "docker rm" requires at least 1 argument. See 'docker rm --help'. Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...] Remove one or more containers ---------删除镜像(:1.0-SNAPSHOT)--------- Error response from daemon: invalid reference format ---------构建新镜像(:1.0-SNAPSHOT)--------- invalid argument ":1.0-SNAPSHOT" for "-t, --tag" flag: invalid reference format See 'docker build --help'. ---------运行服务--------- docker: invalid reference format: repository name must be lowercase. See 'docker run --help'. Build step 'Execute shell' marked build as failure Finished: FAILURE
06-30
可是你没有帮我整理那些仓库里的文件啊 它们还在那 “PS C:\Users\Administrator\Desktop> # ===== 修复Pip下载问题 ===== PS C:\Users\Administrator\Desktop> function Repair-PipConfiguration { >> # 重置pip配置文件 >> $configDir = "C:\ProgramData\pip" >> $pipConfig = @" >> [global] >> index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> trusted-host = pypi.tuna.tsinghua.edu.cn >> "@ >> >> $pipConfig | Out-File "$configDir\pip.ini" -Encoding ASCII -Force >> >> # 清除问题环境变量 >> [Environment]::SetEnvironmentVariable("PIP_CACHE_DIR", $null, "Machine") >> [Environment]::SetEnvironmentVariable("PIP_DOWNLOAD_CACHE", $null, "Machine") >> >> Write-Host "✅ Pip配置已重置" -ForegroundColor Green >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 修复网络驱动器映射 ===== PS C:\Users\Administrator\Desktop> function Initialize-NetworkRepository { >> param( >> [string]$NetworkPath = "\\server\pip_repository", >> [string]$LocalMount = "P:" >> ) >> >> # 使用net use代替New-PSDrive >> net use $LocalMount $NetworkPath /persistent:yes >> >> if ($LASTEXITCODE -ne 0) { >> Write-Host "❌ 网络驱动器映射失败" -ForegroundColor Red >> return >> } >> >> # 初始化仓库 >> Initialize-PipRepository -RepositoryPath "${LocalMount}\" >> >> Write-Host "✅ 网络仓库已映射到: ${LocalMount}\" -ForegroundColor Green >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 增强的下载函数 ===== PS C:\Users\Administrator\Desktop> function Install-FromRepository { >> param( >> [Parameter(Mandatory=$true)] >> [string]$PackageName, >> [string]$Version = "latest", >> [string]$RepositoryPath = "E:\ai_pip_repository" >> ) >> >> $downloadedDir = Join-Path $RepositoryPath "downloaded_packages" >> >> # 搜索本地仓库 >> $localPackages = Get-ChildItem -Path $downloadedDir -Recurse -ErrorAction SilentlyContinue | >> Where-Object { $_.Name -like "*$PackageName*" -and $_.Extension -in @('.whl', '.gz', '.zip') } >> >> if ($localPackages) { >> # 版本选择逻辑 >> if ($Version -eq "latest") { >> $selectedPackage = $localPackages | >> Sort-Object { [regex]::Match($_.Name, '(\d+\.)+\d+').Value } -Descending | >> Select-Object -First 1 >> } else { >> $selectedPackage = $localPackages | >> Where-Object { $_.Name -match "$PackageName-$Version" } | >> Select-Object -First 1 >> } >> >> if (-not $selectedPackage) { >> Write-Host "⚠️ 仓库中未找到指定版本: $PackageName==$Version" -ForegroundColor Yellow >> return >> } >> >> Write-Host "🚀 使用仓库中的版本: $($selectedPackage.Name)" -ForegroundColor Yellow >> >> # 安装主包 >> python -m pip install $selectedPackage.FullName --no-deps --no-index >> >> # 安装依赖 >> $depReport = Test-RepositoryDependency -PackageName $PackageName -RepositoryPath $RepositoryPath >> if ($depReport.MissingDependencies.Count -gt 0) { >> Write-Host "🔍 安装依赖包..." -ForegroundColor Cyan >> $depReport.MissingDependencies | ForEach-Object { >> Install-FromRepository $_ -RepositoryPath $RepositoryPath >> } >> } >> return >> } >> >> # 本地仓库不存在则下载并保存 >> Write-Host "🌐 从镜像下载: $PackageName" -ForegroundColor Magenta >> >> # 创建临时下载目录 >> $tempDir = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString()) >> New-Item -ItemType Directory -Path $tempDir -Force | Out-Null >> >> try { >> # 下载包 - 使用临时配置文件 >> $tempConfig = Join-Path $tempDir "pip_temp.conf" >> @" >> [global] >> index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> trusted-host = pypi.tuna.tsinghua.edu.cn >> "@ | Out-File $tempConfig -Encoding ASCII >> >> if ($Version -eq "latest") { >> python -m pip download $PackageName -d $tempDir --config $tempConfig >> } else { >> python -m pip download "${PackageName}==${Version}" -d $tempDir --config $tempConfig >> } >> >> # 获取下载的文件 >> $downloadedFiles = Get-ChildItem $tempDir -File -ErrorAction SilentlyContinue | >> Where-Object { $_.Extension -in @('.whl', '.gz', '.zip') } >> >> if (-not $downloadedFiles) { >> throw "未找到下载的包文件" >> } >> >> # 安装并保存每个包 >> foreach ($file in $downloadedFiles) { >> # 安装主包 >> python -m pip install $file.FullName --config $tempConfig >> >> # 保存到仓库 >> $savePath = Join-Path $downloadedDir $file.Name >> Copy-Item -Path $file.FullName -Destination $savePath -Force >> Write-Host "💾 已保存到仓库: $($file.Name)" -ForegroundColor Green >> } >> } >> catch { >> Write-Host "❌ 安装失败: $_" -ForegroundColor Red >> } >> finally { >> # 清理临时目录 >> Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue >> } >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 验证函数 ===== PS C:\Users\Administrator\Desktop> function Test-PipFunctionality { >> # 测试基本功能 >> try { >> $result = python -m pip --version >> Write-Host "✅ Pip功能正常: $result" -ForegroundColor Green >> return $true >> } >> catch { >> Write-Host "❌ Pip功能异常: $_" -ForegroundColor Red >> return $false >> } >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 1. 修复pip配置 PS C:\Users\Administrator\Desktop> Repair-PipConfiguration ✅ Pip配置已重置 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 2. 验证pip功能 PS C:\Users\Administrator\Desktop> if (-not (Test-PipFunctionality)) { >> Write-Host "请先修复pip安装" -ForegroundColor Red >> exit >> } ✅ Pip功能正常: pip 25.2 from E:\Python310\lib\site-packages\pip (python 3.10) PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 3. 初始化仓库(如果需要) PS C:\Users\Administrator\Desktop> Initialize-PipRepository -RepositoryPath "E:\ai_pip_repository" Initialize-PipRepository : 无法将“Initialize-PipRepository”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查 名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + Initialize-PipRepository -RepositoryPath "E:\ai_pip_repository" + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Initialize-PipRepository:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 4. 安装包(使用修复后的方法) PS C:\Users\Administrator\Desktop> Install-FromRepository "torch" -Version "2.8.0" 🌐 从镜像下载: torch Usage: E:\Python310\python.exe -m pip download [options] <requirement specifier> [package-index-options] ... E:\Python310\python.exe -m pip download [options] -r <requirements file> [package-index-options] ... E:\Python310\python.exe -m pip download [options] <vcs project url> ... E:\Python310\python.exe -m pip download [options] <local project path> ... E:\Python310\python.exe -m pip download [options] <archive url/path> ... no such option: --config ❌ 安装失败: 未找到下载的包文件 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 5. 更新索引 PS C:\Users\Administrator\Desktop> Update-RepositoryIndex Update-RepositoryIndex : 无法将“Update-RepositoryIndex”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称 的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + Update-RepositoryIndex + ~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Update-RepositoryIndex:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 6. 检查依赖 PS C:\Users\Administrator\Desktop> Test-RepositoryDependency -PackageName "torch" Test-RepositoryDependency : 无法将“Test-RepositoryDependency”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检 查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + Test-RepositoryDependency -PackageName "torch" + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Test-RepositoryDependency:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator\Desktop> # 1. 映射网络驱动器 PS C:\Users\Administrator\Desktop> Initialize-NetworkRepository -NetworkPath "\\192.168.1.100\pip_repo" -LocalMount "P" 发生系统错误 67。 找不到网络名。 ❌ 网络驱动器映射失败 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 2. 使用网络仓库 PS C:\Users\Administrator\Desktop> Install-FromRepository "numpy" -RepositoryPath "P:\" Join-Path : 找不到驱动器。名为“P”的驱动器不存在。 所在位置 行:9 字符: 22 + $downloadedDir = Join-Path $RepositoryPath "downloaded_packages" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (P:String) [Join-Path], DriveNotFoundException + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.JoinPathCommand 🌐 从镜像下载: numpy Usage: E:\Python310\python.exe -m pip download [options] <requirement specifier> [package-index-options] ... E:\Python310\python.exe -m pip download [options] -r <requirements file> [package-index-options] ... E:\Python310\python.exe -m pip download [options] <vcs project url> ... E:\Python310\python.exe -m pip download [options] <local project path> ... E:\Python310\python.exe -m pip download [options] <archive url/path> ... no such option: --config ❌ 安装失败: 未找到下载的包文件 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 1. 修复Python环境 ===== PS C:\Users\Administrator\Desktop> function Repair-PythonEnvironment { >> param( >> [string]$PythonPath = "E:\Python310" >> ) >> >> # 验证Python安装 >> if (-not (Test-Path $PythonPath)) { >> Write-Host "❌ Python路径不存在: $PythonPath" -ForegroundColor Red >> return $false >> } >> >> # 修复pip安装 >> try { >> Write-Host "🔧 修复pip安装..." -ForegroundColor Cyan >> $requirements = Join-Path $env:TEMP "requirements.txt" >> python -m pip freeze > $requirements >> python -m pip uninstall -y -r $requirements >> python -m ensurepip --upgrade >> python -m pip install --upgrade pip setuptools wheel >> Remove-Item $requirements -Force >> } >> catch { >> Write-Host "❌ pip修复失败: $_" -ForegroundColor Red >> return $false >> } >> >> # 验证修复 >> try { >> $pipVersion = python -m pip --version >> Write-Host "✅ pip已修复: $pipVersion" -ForegroundColor Green >> return $true >> } >> catch { >> Write-Host "❌ pip验证失败" -ForegroundColor Red >> return $false >> } >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 2. 修复.NET SDK安装 ===== PS C:\Users\Administrator\Desktop> function Install-DotNetSDK { >> param( >> [string]$Version = "9.0.109" >> ) >> >> # 清理旧安装 >> Write-Host "🧹 清理旧.NET安装..." -ForegroundColor Cyan >> $dotnetPath = "C:\Program Files\dotnet" >> if (Test-Path $dotnetPath) { >> Remove-Item $dotnetPath -Recurse -Force -ErrorAction SilentlyContinue >> } >> >> # 下载安装程序 >> $installerPath = "$env:TEMP\dotnet-sdk-installer.exe" >> $downloadUrl = "https://download.visualstudio.microsoft.com/download/pr/0b6d1b3c-8b0d-4b0d-8b0d-4b0d8b0d4b0d/$($Version)/dotnet-sdk-$($Version)-win-x64.exe" >> >> try { >> Write-Host "📥 下载.NET SDK $Version..." -ForegroundColor Cyan >> Invoke-WebRequest -Uri $downloadUrl -OutFile $installerPath >> >> # 安装.NET SDK >> Write-Host "⚙️ 安装.NET SDK..." -ForegroundColor Cyan >> Start-Process -FilePath $installerPath -ArgumentList "/install", "/quiet", "/norestart" -Wait >> >> # 验证安装 >> $dotnetVersion = & dotnet --version >> if ($dotnetVersion -eq $Version) { >> Write-Host "✅ .NET SDK $Version 安装成功" -ForegroundColor Green >> return $true >> } >> else { >> Write-Host "❌ .NET SDK 安装验证失败" -ForegroundColor Red >> return $false >> } >> } >> catch { >> Write-Host "❌ .NET SDK 安装失败: $_" -ForegroundColor Red >> return $false >> } >> finally { >> Remove-Item $installerPath -Force -ErrorAction SilentlyContinue >> } >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 3. 增强的pip仓库函数 ===== PS C:\Users\Administrator\Desktop> function Initialize-PipRepository { >> param( >> [string]$RepositoryPath = "E:\ai_pip_repository" >> ) >> >> # 创建仓库目录结构 >> $repoStructure = @{ >> Wheels = "wheels" >> SourceDists = "source_distributions" >> TempUnpack = "temp_unpack" >> Metadata = "metadata" >> Downloaded = "downloaded_packages" >> } >> >> # 创建仓库目录 >> try { >> New-Item -Path $RepositoryPath -ItemType Directory -Force | Out-Null >> $repoStructure.Keys | ForEach-Object { >> $dirPath = Join-Path $RepositoryPath $repoStructure[$_] >> New-Item -Path $dirPath -ItemType Directory -Force | Out-Null >> } >> } >> catch { >> Write-Host "❌ 目录创建失败: $_" -ForegroundColor Red >> return >> } >> >> # 简化pip配置 >> $pipConfig = @" >> [global] >> index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> trusted-host = pypi.tuna.tsinghua.edu.cn >> "@ >> >> # 写入pip配置文件 >> $configDir = "C:\ProgramData\pip" >> if (-not (Test-Path $configDir)) { >> New-Item -ItemType Directory -Path $configDir -Force | Out-Null >> } >> $pipConfig | Out-File "$configDir\pip.ini" -Encoding ASCII -Force >> >> Write-Host "✅ Pip仓库已初始化: $RepositoryPath" -ForegroundColor Green >> Write-Host "仓库结构:" >> $repoStructure.GetEnumerator() | Format-Table @{Name="类型"; Expression={$_.Key}}, @{Name="路径"; Expression={$_.Value}} >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 4. 安全安装函数 ===== PS C:\Users\Administrator\Desktop> function Install-FromRepository { >> param( >> [Parameter(Mandatory=$true)] >> [string]$PackageName, >> [string]$Version = "latest", >> [string]$RepositoryPath = "E:\ai_pip_repository" >> ) >> >> # 创建临时配置文件 >> $tempConfig = Join-Path $env:TEMP "pip_temp.conf" >> @" >> [global] >> index-url = https://pypi.tuna.tsinghua.edu.cn/simple >> trusted-host = pypi.tuna.tsinghua.edu.cn >> "@ | Out-File $tempConfig -Encoding ASCII >> >> $downloadedDir = Join-Path $RepositoryPath "downloaded_packages" >> >> # 搜索本地仓库 >> $localPackages = Get-ChildItem -Path $downloadedDir -Recurse -ErrorAction SilentlyContinue | >> Where-Object { $_.Name -like "*$PackageName*" -and $_.Extension -in @('.whl', '.gz', '.zip') } >> >> if ($localPackages) { >> # 版本选择逻辑 >> if ($Version -eq "latest") { >> $selectedPackage = $localPackages | >> Sort-Object { [regex]::Match($_.Name, '(\d+\.)+\d+').Value } -Descending | >> Select-Object -First 1 >> } else { >> $selectedPackage = $localPackages | >> Where-Object { $_.Name -match "$PackageName-$Version" } | >> Select-Object -First 1 >> } >> >> if (-not $selectedPackage) { >> Write-Host "⚠️ 仓库中未找到指定版本: $PackageName==$Version" -ForegroundColor Yellow >> return >> } >> >> Write-Host "🚀 使用仓库中的版本: $($selectedPackage.Name)" -ForegroundColor Yellow >> >> # 安装主包 >> python -m pip install $selectedPackage.FullName --no-deps --no-index --config $tempConfig >> >> # 安装依赖 >> $depReport = Test-RepositoryDependency -PackageName $PackageName -RepositoryPath $RepositoryPath >> if ($depReport.MissingDependencies.Count -gt 0) { >> Write-Host "🔍 安装依赖包..." -ForegroundColor Cyan >> $depReport.MissingDependencies | ForEach-Object { >> Install-FromRepository $_ -RepositoryPath $RepositoryPath --config $tempConfig >> } >> } >> return >> } >> >> # 本地仓库不存在则下载并保存 >> Write-Host "🌐 从镜像下载: $PackageName" -ForegroundColor Magenta >> >> # 创建临时下载目录 >> $tempDir = Join-Path $env:TEMP ([System.Guid]::NewGuid().ToString()) >> New-Item -ItemType Directory -Path $tempDir -Force | Out-Null >> >> try { >> # 下载包 >> if ($Version -eq "latest") { >> python -m pip download $PackageName -d $tempDir --config $tempConfig >> } else { >> python -m pip download "${PackageName}==${Version}" -d $tempDir --config $tempConfig >> } >> >> # 获取下载的文件 >> $downloadedFiles = Get-ChildItem $tempDir -File -ErrorAction SilentlyContinue | >> Where-Object { $_.Extension -in @('.whl', '.gz', '.zip') } >> >> if (-not $downloadedFiles) { >> throw "未找到下载的包文件" >> } >> >> # 安装并保存每个包 >> foreach ($file in $downloadedFiles) { >> # 安装主包 >> python -m pip install $file.FullName --config $tempConfig >> >> # 保存到仓库 >> $savePath = Join-Path $downloadedDir $file.Name >> Copy-Item -Path $file.FullName -Destination $savePath -Force >> Write-Host "💾 已保存到仓库: $($file.Name)" -ForegroundColor Green >> } >> } >> catch { >> Write-Host "❌ 安装失败: $_" -ForegroundColor Red >> } >> finally { >> # 清理临时目录 >> Remove-Item $tempDir -Recurse -Force -ErrorAction SilentlyContinue >> Remove-Item $tempConfig -Force -ErrorAction SilentlyContinue >> } >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 5. 网络驱动器解决方案 ===== PS C:\Users\Administrator\Desktop> function Map-NetworkDrive { >> param( >> [string]$NetworkPath, >> [string]$DriveLetter = "P" >> ) >> >> # 移除现有映射 >> net use ${DriveLetter}: /delete /y 2>$null >> >> # 创建新映射 >> net use ${DriveLetter}: $NetworkPath /persistent:yes >> >> if ($LASTEXITCODE -ne 0) { >> Write-Host "❌ 网络驱动器映射失败" -ForegroundColor Red >> return $null >> } >> >> Write-Host "✅ 网络驱动器已映射: ${DriveLetter}:\ -> $NetworkPath" -ForegroundColor Green >> return "${DriveLetter}:" >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # ===== 6. 环境验证函数 ===== PS C:\Users\Administrator\Desktop> function Test-Environment { >> # 验证Python >> try { >> $pythonVersion = python --version >> Write-Host "✅ Python可用: $pythonVersion" -ForegroundColor Green >> } >> catch { >> Write-Host "❌ Python不可用" -ForegroundColor Red >> return $false >> } >> >> # 验证pip >> try { >> $pipVersion = python -m pip --version >> Write-Host "✅ pip可用: $pipVersion" -ForegroundColor Green >> } >> catch { >> Write-Host "❌ pip不可用" -ForegroundColor Red >> return $false >> } >> >> # 验证.NET >> try { >> $dotnetVersion = dotnet --version >> Write-Host "✅ .NET SDK可用: $dotnetVersion" -ForegroundColor Green >> } >> catch { >> Write-Host "⚠️ .NET SDK不可用" -ForegroundColor Yellow >> } >> >> return $true >> } PS C:\Users\Administrator\Desktop> # 1. 修复Python环境 PS C:\Users\Administrator\Desktop> Repair-PythonEnvironment 🔧 修复pip安装... WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Found existing installation: certifi 2025.8.3 Uninstalling certifi-2025.8.3: Successfully uninstalled certifi-2025.8.3 Found existing installation: charset-normalizer 3.4.3 Uninstalling charset-normalizer-3.4.3: Successfully uninstalled charset-normalizer-3.4.3 Found existing installation: click 8.2.1 Uninstalling click-8.2.1: Successfully uninstalled click-8.2.1 Found existing installation: colorama 0.4.6 Uninstalling colorama-0.4.6: Successfully uninstalled colorama-0.4.6 Found existing installation: filelock 3.19.1 Uninstalling filelock-3.19.1: Successfully uninstalled filelock-3.19.1 Found existing installation: Flask 3.1.1 Uninstalling Flask-3.1.1: Successfully uninstalled Flask-3.1.1 Found existing installation: flask-cors 6.0.1 Uninstalling flask-cors-6.0.1: Successfully uninstalled flask-cors-6.0.1 Found existing installation: Flask-Limiter 3.12 Uninstalling Flask-Limiter-3.12: Successfully uninstalled Flask-Limiter-3.12 Found existing installation: Flask-SocketIO 5.5.1 Uninstalling Flask-SocketIO-5.5.1: Successfully uninstalled Flask-SocketIO-5.5.1 Found existing installation: fonttools 4.59.0 Uninstalling fonttools-4.59.0: Successfully uninstalled fonttools-4.59.0 Found existing installation: fsspec 2025.7.0 Uninstalling fsspec-2025.7.0: Successfully uninstalled fsspec-2025.7.0 Found existing installation: future 1.0.0 Uninstalling future-1.0.0: Successfully uninstalled future-1.0.0 Found existing installation: GPUtil 1.4.0 Uninstalling GPUtil-1.4.0: Successfully uninstalled GPUtil-1.4.0 Found existing installation: gradio 3.41.0 Uninstalling gradio-3.41.0: Successfully uninstalled gradio-3.41.0 Found existing installation: gradio_client 0.5.0 Uninstalling gradio_client-0.5.0: Successfully uninstalled gradio_client-0.5.0 Found existing installation: greenlet 3.2.4 Uninstalling greenlet-3.2.4: Successfully uninstalled greenlet-3.2.4 Found existing installation: groovy 0.1.2 Uninstalling groovy-0.1.2: Successfully uninstalled groovy-0.1.2 Found existing installation: grpcio 1.74.0 Uninstalling grpcio-1.74.0: Successfully uninstalled grpcio-1.74.0 Found existing installation: h11 0.16.0 Uninstalling h11-0.16.0: Successfully uninstalled h11-0.16.0 Found existing installation: httpcore 1.0.9 Uninstalling httpcore-1.0.9: Successfully uninstalled httpcore-1.0.9 Found existing installation: httpx 0.28.1 Uninstalling httpx-0.28.1: Successfully uninstalled httpx-0.28.1 Found existing installation: huggingface-hub 0.34.3 Uninstalling huggingface-hub-0.34.3: Successfully uninstalled huggingface-hub-0.34.3 Found existing installation: idna 3.10 Uninstalling idna-3.10: Successfully uninstalled idna-3.10 Found existing installation: imageio 2.37.0 Uninstalling imageio-2.37.0: Successfully uninstalled imageio-2.37.0 Found existing installation: importlib_metadata 8.7.0 Uninstalling importlib_metadata-8.7.0: Successfully uninstalled importlib_metadata-8.7.0 Found existing installation: importlib_resources 6.5.2 Uninstalling importlib_resources-6.5.2: Successfully uninstalled importlib_resources-6.5.2 Found existing installation: itsdangerous 2.2.0 Uninstalling itsdangerous-2.2.0: Successfully uninstalled itsdangerous-2.2.0 Found existing installation: Jinja2 3.1.6 Uninstalling Jinja2-3.1.6: Successfully uninstalled Jinja2-3.1.6 Found existing installation: jsonschema 4.25.0 Uninstalling jsonschema-4.25.0: Successfully uninstalled jsonschema-4.25.0 Found existing installation: jsonschema-specifications 2025.4.1 Uninstalling jsonschema-specifications-2025.4.1: Successfully uninstalled jsonschema-specifications-2025.4.1 Found existing installation: kiwisolver 1.4.8 Uninstalling kiwisolver-1.4.8: Successfully uninstalled kiwisolver-1.4.8 Found existing installation: lazy_loader 0.4 Uninstalling lazy_loader-0.4: Successfully uninstalled lazy_loader-0.4 Found existing installation: limits 5.5.0 Uninstalling limits-5.5.0: Successfully uninstalled limits-5.5.0 Found existing installation: lmdb 1.7.3 Uninstalling lmdb-1.7.3: Successfully uninstalled lmdb-1.7.3 Found existing installation: Markdown 3.8.2 Uninstalling Markdown-3.8.2: Successfully uninstalled Markdown-3.8.2 Found existing installation: markdown-it-py 3.0.0 Uninstalling markdown-it-py-3.0.0: Successfully uninstalled markdown-it-py-3.0.0 Found existing installation: MarkupSafe 2.1.5 Uninstalling MarkupSafe-2.1.5: Successfully uninstalled MarkupSafe-2.1.5 Found existing installation: matplotlib 3.10.5 Uninstalling matplotlib-3.10.5: Successfully uninstalled matplotlib-3.10.5 Found existing installation: mdurl 0.1.2 Uninstalling mdurl-0.1.2: Successfully uninstalled mdurl-0.1.2 Found existing installation: modelscope 1.29.0 Uninstalling modelscope-1.29.0: Successfully uninstalled modelscope-1.29.0 Found existing installation: mpmath 1.3.0 Uninstalling mpmath-1.3.0: Successfully uninstalled mpmath-1.3.0 Found existing installation: narwhals 2.0.1 Uninstalling narwhals-2.0.1: Successfully uninstalled narwhals-2.0.1 Found existing installation: networkx 3.4.2 Uninstalling networkx-3.4.2: Successfully uninstalled networkx-3.4.2 Found existing installation: numpy 2.2.6 Uninstalling numpy-2.2.6: Successfully uninstalled numpy-2.2.6 Found existing installation: opencv-python 4.12.0.88 Uninstalling opencv-python-4.12.0.88: Successfully uninstalled opencv-python-4.12.0.88 Found existing installation: ordered-set 4.1.0 Uninstalling ordered-set-4.1.0: Successfully uninstalled ordered-set-4.1.0 Found existing installation: orjson 3.11.1 Uninstalling orjson-3.11.1: Successfully uninstalled orjson-3.11.1 Found existing installation: packaging 25.0 Uninstalling packaging-25.0: Successfully uninstalled packaging-25.0 Found existing installation: pandas 2.3.1 Uninstalling pandas-2.3.1: Successfully uninstalled pandas-2.3.1 Found existing installation: pillow 10.4.0 Uninstalling pillow-10.4.0: Successfully uninstalled pillow-10.4.0 Found existing installation: platformdirs 4.3.8 Uninstalling platformdirs-4.3.8: Successfully uninstalled platformdirs-4.3.8 Found existing installation: prometheus_client 0.22.1 Uninstalling prometheus_client-0.22.1: Successfully uninstalled prometheus_client-0.22.1 Found existing installation: protobuf 6.31.1 Uninstalling protobuf-6.31.1: Successfully uninstalled protobuf-6.31.1 Found existing installation: psutil 7.0.0 Uninstalling psutil-7.0.0: Successfully uninstalled psutil-7.0.0 Found existing installation: pycparser 2.22 Uninstalling pycparser-2.22: Successfully uninstalled pycparser-2.22 Found existing installation: pycryptodome 3.18.0 Uninstalling pycryptodome-3.18.0: Successfully uninstalled pycryptodome-3.18.0 Found existing installation: pydantic 2.11.7 Uninstalling pydantic-2.11.7: Successfully uninstalled pydantic-2.11.7 Found existing installation: pydantic_core 2.33.2 Uninstalling pydantic_core-2.33.2: Successfully uninstalled pydantic_core-2.33.2 Found existing installation: pydub 0.25.1 Uninstalling pydub-0.25.1: Successfully uninstalled pydub-0.25.1 Found existing installation: Pygments 2.19.2 Uninstalling Pygments-2.19.2: Successfully uninstalled Pygments-2.19.2 Found existing installation: pyparsing 3.2.3 Uninstalling pyparsing-3.2.3: Successfully uninstalled pyparsing-3.2.3 Found existing installation: python-dateutil 2.9.0.post0 Uninstalling python-dateutil-2.9.0.post0: Successfully uninstalled python-dateutil-2.9.0.post0 Found existing installation: python-dotenv 1.1.1 Uninstalling python-dotenv-1.1.1: Successfully uninstalled python-dotenv-1.1.1 Found existing installation: python-engineio 4.12.2 Uninstalling python-engineio-4.12.2: Successfully uninstalled python-engineio-4.12.2 Found existing installation: python-multipart 0.0.20 Uninstalling python-multipart-0.0.20: Successfully uninstalled python-multipart-0.0.20 Found existing installation: python-socketio 5.13.0 Uninstalling python-socketio-5.13.0: Successfully uninstalled python-socketio-5.13.0 Found existing installation: pytz 2025.2 Uninstalling pytz-2025.2: Successfully uninstalled pytz-2025.2 Found existing installation: pywin32 311 Uninstalling pywin32-311: Successfully uninstalled pywin32-311 Found existing installation: PyYAML 6.0.2 Uninstalling PyYAML-6.0.2: Successfully uninstalled PyYAML-6.0.2 Found existing installation: referencing 0.36.2 Uninstalling referencing-0.36.2: Successfully uninstalled referencing-0.36.2 Found existing installation: regex 2025.7.34 Uninstalling regex-2025.7.34: Successfully uninstalled regex-2025.7.34 Found existing installation: requests 2.32.5 Uninstalling requests-2.32.5: Successfully uninstalled requests-2.32.5 Found existing installation: rich 13.9.4 Uninstalling rich-13.9.4: Successfully uninstalled rich-13.9.4 Found existing installation: rpds-py 0.26.0 Uninstalling rpds-py-0.26.0: Successfully uninstalled rpds-py-0.26.0 Found existing installation: ruff 0.12.7 Uninstalling ruff-0.12.7: Successfully uninstalled ruff-0.12.7 Found existing installation: safehttpx 0.1.6 Uninstalling safehttpx-0.1.6: Successfully uninstalled safehttpx-0.1.6 Found existing installation: safetensors 0.5.3 Uninstalling safetensors-0.5.3: Successfully uninstalled safetensors-0.5.3 Found existing installation: scikit-image 0.25.2 Uninstalling scikit-image-0.25.2: Successfully uninstalled scikit-image-0.25.2 Found existing installation: scipy 1.15.3 Uninstalling scipy-1.15.3: Successfully uninstalled scipy-1.15.3 Found existing installation: semantic-version 2.10.0 Uninstalling semantic-version-2.10.0: Successfully uninstalled semantic-version-2.10.0 Found existing installation: sentencepiece 0.2.0 Uninstalling sentencepiece-0.2.0: Successfully uninstalled sentencepiece-0.2.0 Found existing installation: shellingham 1.5.4 Uninstalling shellingham-1.5.4: Successfully uninstalled shellingham-1.5.4 Found existing installation: simple-websocket 1.1.0 Uninstalling simple-websocket-1.1.0: Successfully uninstalled simple-websocket-1.1.0 Found existing installation: six 1.17.0 Uninstalling six-1.17.0: Successfully uninstalled six-1.17.0 Found existing installation: sniffio 1.3.1 Uninstalling sniffio-1.3.1: Successfully uninstalled sniffio-1.3.1 Found existing installation: starlette 0.47.2 Uninstalling starlette-0.47.2: Successfully uninstalled starlette-0.47.2 Found existing installation: sympy 1.13.3 Uninstalling sympy-1.13.3: Successfully uninstalled sympy-1.13.3 Found existing installation: tensorboard 2.20.0 Uninstalling tensorboard-2.20.0: Successfully uninstalled tensorboard-2.20.0 Found existing installation: tensorboard-data-server 0.7.2 Uninstalling tensorboard-data-server-0.7.2: Successfully uninstalled tensorboard-data-server-0.7.2 Found existing installation: tifffile 2025.5.10 Uninstalling tifffile-2025.5.10: Successfully uninstalled tifffile-2025.5.10 Found existing installation: tiktoken 0.9.0 Uninstalling tiktoken-0.9.0: Successfully uninstalled tiktoken-0.9.0 Found existing installation: tokenizers 0.13.3 Uninstalling tokenizers-0.13.3: Successfully uninstalled tokenizers-0.13.3 Found existing installation: tomli 2.2.1 Uninstalling tomli-2.2.1: Successfully uninstalled tomli-2.2.1 Found existing installation: tomlkit 0.12.0 Uninstalling tomlkit-0.12.0: Successfully uninstalled tomlkit-0.12.0 Found existing installation: torch 2.0.1 Uninstalling torch-2.0.1: Successfully uninstalled torch-2.0.1 Found existing installation: torchaudio 2.8.0+cpu Uninstalling torchaudio-2.8.0+cpu: Successfully uninstalled torchaudio-2.8.0+cpu Found existing installation: torchvision 0.23.0+cpu Uninstalling torchvision-0.23.0+cpu: Successfully uninstalled torchvision-0.23.0+cpu Found existing installation: tqdm 4.67.1 Uninstalling tqdm-4.67.1: Successfully uninstalled tqdm-4.67.1 Found existing installation: transformers 4.31.0 Uninstalling transformers-4.31.0: Successfully uninstalled transformers-4.31.0 Found existing installation: typer 0.16.0 Uninstalling typer-0.16.0: Successfully uninstalled typer-0.16.0 Found existing installation: typing-inspection 0.4.1 Uninstalling typing-inspection-0.4.1: Successfully uninstalled typing-inspection-0.4.1 Found existing installation: typing_extensions 4.14.1 Uninstalling typing_extensions-4.14.1: Successfully uninstalled typing_extensions-4.14.1 Found existing installation: tzdata 2025.2 Uninstalling tzdata-2025.2: Successfully uninstalled tzdata-2025.2 Found existing installation: urllib3 2.5.0 Uninstalling urllib3-2.5.0: Successfully uninstalled urllib3-2.5.0 Found existing installation: uvicorn 0.35.0 Uninstalling uvicorn-0.35.0: Successfully uninstalled uvicorn-0.35.0 Found existing installation: waitress 3.0.2 Uninstalling waitress-3.0.2: Successfully uninstalled waitress-3.0.2 Found existing installation: watchdog 6.0.0 Uninstalling watchdog-6.0.0: Successfully uninstalled watchdog-6.0.0 Found existing installation: websockets 11.0.3 Uninstalling websockets-11.0.3: Successfully uninstalled websockets-11.0.3 Found existing installation: Werkzeug 3.1.3 Uninstalling Werkzeug-3.1.3: Successfully uninstalled Werkzeug-3.1.3 Found existing installation: WMI 1.5.1 Uninstalling WMI-1.5.1: Successfully uninstalled WMI-1.5.1 Found existing installation: wrapt 1.17.2 Uninstalling wrapt-1.17.2: Successfully uninstalled wrapt-1.17.2 Found existing installation: wsproto 1.2.0 Uninstalling wsproto-1.2.0: Successfully uninstalled wsproto-1.2.0 Found existing installation: yapf 0.43.0 Uninstalling yapf-0.43.0: Successfully uninstalled yapf-0.43.0 Found existing installation: zipp 3.23.0 Uninstalling zipp-3.23.0: Successfully uninstalled zipp-3.23.0 WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Looking in links: c:\Users\ADMINI~1\AppData\Local\Temp\tmpcpohcgy2 Requirement already satisfied: setuptools in e:\python310\lib\site-packages (80.9.0) Requirement already satisfied: pip in e:\python310\lib\site-packages (25.2) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: pip in e:\python310\lib\site-packages (25.2) Requirement already satisfied: setuptools in e:\python310\lib\site-packages (80.9.0) Collecting wheel Downloading https://pypi.tuna.tsinghua.edu.cn/packages/0b/2c/87f3254fd8ffd29e4c02732eee68a83a1d3c346ae39bc6822dcbcb697f2b/wheel-0.45.1-py3-none-any.whl (72 kB) WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Installing collected packages: wheel WARNING: The script wheel.exe is installed in 'E:\Python310\Scripts' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. WARNING: Ignoring invalid distribution -odelscope (e:\python310\lib\site-packages) Successfully installed wheel-0.45.1 WARNING: There was an error checking the latest version of pip. ✅ pip已修复: pip 25.2 from E:\Python310\lib\site-packages\pip (python 3.10) True PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 2. 安装/修复.NET SDK PS C:\Users\Administrator\Desktop> Install-DotNetSDK -Version "9.0.109" 🧹 清理旧.NET安装... 📥 下载.NET SDK 9.0.109... ❌ .NET SDK 安装失败: 远程服务器返回错误: (400) 错误的请求。 False PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 3. 初始化pip仓库 PS C:\Users\Administrator\Desktop> Initialize-PipRepository -RepositoryPath "E:\ai_pip_repository" ✅ Pip仓库已初始化: E:\ai_pip_repository 仓库结构: 类型 路径 ---- ---- Metadata metadata Wheels wheels SourceDists source_distributions Downloaded downloaded_packages TempUnpack temp_unpack PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 4. 映射网络驱动器(如果需要) PS C:\Users\Administrator\Desktop> $drive = Map-NetworkDrive -NetworkPath "\\192.168.1.100\pip_repo" -DriveLetter "P" 发生系统错误 67。 找不到网络名。 ❌ 网络驱动器映射失败 PS C:\Users\Administrator\Desktop> if ($drive) { >> Initialize-PipRepository -RepositoryPath "${drive}\" >> } PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 5. 验证环境 PS C:\Users\Administrator\Desktop> Test-Environment ✅ Python可用: Python 3.10.10 ✅ pip可用: pip 25.2 from E:\Python310\lib\site-packages\pip (python 3.10) ⚠️ .NET SDK不可用 True PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 6. 安装包 PS C:\Users\Administrator\Desktop> Install-FromRepository "torch" -Version "2.8.0" 🌐 从镜像下载: torch Usage: E:\Python310\python.exe -m pip download [options] <requirement specifier> [package-index-options] ... E:\Python310\python.exe -m pip download [options] -r <requirements file> [package-index-options] ... E:\Python310\python.exe -m pip download [options] <vcs project url> ... E:\Python310\python.exe -m pip download [options] <local project path> ... E:\Python310\python.exe -m pip download [options] <archive url/path> ... no such option: --config ❌ 安装失败: 未找到下载的包文件 PS C:\Users\Administrator\Desktop> Install-FromRepository "torchvision" -Version "0.15.1" 🌐 从镜像下载: torchvision Usage: E:\Python310\python.exe -m pip download [options] <requirement specifier> [package-index-options] ... E:\Python310\python.exe -m pip download [options] -r <requirements file> [package-index-options] ... E:\Python310\python.exe -m pip download [options] <vcs project url> ... E:\Python310\python.exe -m pip download [options] <local project path> ... E:\Python310\python.exe -m pip download [options] <archive url/path> ... no such option: --config ❌ 安装失败: 未找到下载的包文件 PS C:\Users\Administrator\Desktop> Install-FromRepository "torchaudio" -Version "2.0.1" 🌐 从镜像下载: torchaudio Usage: E:\Python310\python.exe -m pip download [options] <requirement specifier> [package-index-options] ... E:\Python310\python.exe -m pip download [options] -r <requirements file> [package-index-options] ... E:\Python310\python.exe -m pip download [options] <vcs project url> ... E:\Python310\python.exe -m pip download [options] <local project path> ... E:\Python310\python.exe -m pip download [options] <archive url/path> ... no such option: --config ❌ 安装失败: 未找到下载的包文件 PS C:\Users\Administrator\Desktop> PS C:\Users\Administrator\Desktop> # 生成诊断报告 PS C:\Users\Administrator\Desktop> function Get-EnvironmentDiagnostics { >> $report = @() >> >> # Python信息 >> try { >> $pythonVersion = python --version 2>&1 >> $report += "Python: $pythonVersion" >> } catch { >> $report += "Python: ❌ 不可用" >> } >> >> # pip信息 >> try { >> $pipVersion = python -m pip --version 2>&1 >> $report += "pip: $pipVersion" >> } catch { >> $report += "pip: ❌ 不可用" >> } >> >> # .NET信息 >> try { >> $dotnetVersion = dotnet --version 2>&1 >> $report += ".NET SDK: $dotnetVersion" >> } catch { >> $report += ".NET SDK: ❌ 不可用" >> } >> >> # 环境变量 >> $report += "环境变量PATH: $env:PATH" >> >> # 输出报告 >> $report | Out-File "$env:TEMP\environment_diagnostics.txt" >> Write-Host "诊断报告已保存到: $env:TEMP\environment_diagnostics.txt" -ForegroundColor Cyan >> $report | ForEach-Object { Write-Host $_ } >> } PS C:\Users\Administrator\Desktop>”
最新发布
08-23
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值