活动介绍
file-type

掌握Markdown语法:在GitHub中编写Markdown文件

ZIP文件

下载需积分: 5 | 1KB | 更新于2025-08-14 | 12 浏览量 | 0 下载量 举报 收藏
download 立即下载
在IT行业内,Markdown是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档,然后转换成有效的XHTML(或者HTML)文档。这种语言因其简洁性和易读性,在编写文档和编写代码时非常受欢迎。本文档标题“Write-MarkDown-File-In-Github”指出了将Markdown文件写入GitHub的操作方法,下面将根据描述中的内容,详细解析Markdown在GitHub上的应用及相关语法。 ### Markdown语言基础 #### 标题的写法 Markdown支持多种级别的标题,使用`#`符号来定义标题的级别。例如: - 一级标题:`# 一级标题` 会渲染为 `<h1>一级标题</h1>` - 二级标题:`## 二级标题` 会渲染为 `<h2>二级标题</h2>` - 以此类推,最多可以支持六级标题。 #### 插入链接和图像 Markdown中插入超链接和图像的语法如下: - 插入链接:`[链接名称](http://链接地址)` - 插入图像:`![替代文字](http://图片链接地址)` #### 文本样式 Markdown允许你通过简单的方式来标注文本的样式: - 粗体:使用两个星号`**`或者两个下划线`__`将需要加粗的文本包围起来,例如:`**粗体文本**`。 - 斜体:使用一个星号`*`或者一个下划线`_`将需要斜体的文本包围起来,例如:`_斜体文本_`。 - 引用文本:在文本前加上`>`符号来创建引用效果,例如:`> 这是一个引用`。 #### 段落和代码块 Markdown中,段落是通过一个或多个空行来分隔的文本块: - 段落:正常的段落不需要特别标记,只要连续输入文字即可。 - 代码块:通过缩进(通常四个空格或者一个制表符)或者使用三个反引号包围(```)来表示代码块,例如: ``` 这是一个代码块。 ``` ### 在GitHub中使用Markdown GitHub作为一个代码托管和协作开发平台,广泛使用Markdown来撰写README文件、编写issue、pull request等。在GitHub上使用Markdown时,可以利用GitHub提供的扩展语法: - 任务列表:使用`- [ ]`来添加未完成的任务,使用`- [x]`来标记已完成的任务。 - 表情符号:可以使用英文冒号加表情名称的方式插入emoji,例如:`:smile:` 会被渲染为 😄。 - 删除线:使用两个波浪线`~~`来包围需要加删除线的文本,例如:`~~错误文本~~`。 - 提及用户:在评论中通过`@用户名`的方式来提及GitHub上的其他用户。 - 代码片段:可以用单反引号`来包裹代码片段,例如:`` `代码片段` ``。 ### 实际操作示例 假设你正在GitHub上为你的项目编写README文件,你可能会这样写: ```markdown # 项目名称 ## 介绍 这是一个简单的Markdown文档示例。 ### 功能列表 - [x] 功能1 - [ ] 功能2 - [ ] 功能3 ## 如何贡献 请按照以下步骤参与贡献: 1. 克隆仓库:`git clone https://github.com/your-username/your-repo.git` 2. 创建新分支:`git checkout -b new-feature` 3. 提交更改:`git commit -m 'Add new feature'` 4. 推送更改:`git push origin new-feature` 5. 创建pull request ## 联系方式 如果你有任何问题,请随时通过[GitHub](https://github.com)联系我。 ``` 通过以上内容,你可以在GitHub上使用Markdown语言来编写文档和注释,以便更有效地协作和展示项目信息。

相关推荐

filetype

可是 你没告诉我README.md要保存在哪里啊!? 小蓝窗显示“PS C:\Users\Administrator> # 正确创建配置文件的方法 >> $configContent = @' >> { >> "CurlPath": "E:\\CurlTools\\CurlBin", >> "AllowedDomains": [ >> "example.com", >> "github.com", >> "microsoft.com" >> ] >> } >> '@ >> >> # 确保配置目录存在 >> $configDir = "E:\CurlTools\Config" >> if (-not (Test-Path $configDir)) { >> New-Item -ItemType Directory -Path $configDir -Force | Out-Null >> } >> >> # 保存配置文件 >> $configContent | Out-File "$configDir\config.json" -Encoding UTF8 >> PS C:\Users\Administrator> # 确保日志目录存在 >> $logDir = "E:\CurlTools\Logs" >> if (-not (Test-Path $logDir)) { >> New-Item -ItemType Directory -Path $logDir -Force | Out-Null >> } >> >> function Write-Log { >> param( >> [string]$Message, >> [ValidateSet('Info','Warning','Error')] >> [string]$Level = 'Info' >> ) >> >> $logPath = "$logDir\curl_tools_$(Get-Date -Format 'yyyyMMdd').log" >> $logEntry = "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] [$Level] $Message" >> >> Add-Content -Path $logPath -Value $logEntry >> } >> >> function Get-CurlPath { >> try { >> # 从配置获取curl路径 >> $configPath = "E:\CurlTools\Config\config.json" >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> >> # 验证配置结构 >> if (-not $config.PSObject.Properties.Name -contains 'CurlPath') { >> throw "Config file missing 'CurlPath' property" >> } >> >> $curlDir = $config.CurlPath >> if (-not (Test-Path $curlDir)) { >> throw "CurlPath directory not found: $curlDir" >> } >> >> $curlPath = Join-Path $curlDir "curl.exe" >> >> if (-not (Test-Path $curlPath)) { >> throw "curl.exe not found! Check path: $curlPath" >> } >> >> return $curlPath >> } >> catch { >> Write-Log -Message "Get-CurlPath error: $_" -Level 'Error' >> throw $_ >> } >> } >> >> function Get-CurlVersion { >> try { >> # 获取curl版本信息 >> $curlPath = Get-CurlPath >> $version = & $curlPath --version | Select-Object -First 1 >> return $version >> } >> catch { >> Write-Log -Message "Get-CurlVersion error: $_" -Level 'Error' >> throw $_ >> } >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath >> ) >> >> Write-Log -Message "Starting download: $Url => $OutputPath" -Level 'Info' >> >> try { >> # 检查域名是否允许 >> $uri = [System.Uri]$Url >> $domain = $uri.Host >> >> $configPath = "E:\CurlTools\Config\config.json" >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> >> # 增强域名检查逻辑 >> if (-not $config.PSObject.Properties.Name -contains 'AllowedDomains') { >> throw "Config file missing 'AllowedDomains' property" >> } >> >> if (-not $config.AllowedDomains) { >> throw "No allowed domains configured!" >> } >> >> # 处理子域名:检查主域名是否在允许列表中 >> $isAllowed = $false >> foreach ($allowed in $config.AllowedDomains) { >> if ($domain -eq $allowed -or $domain.EndsWith(".$allowed")) { >> $isAllowed = $true >> break >> } >> } >> >> if (-not $isAllowed) { >> $msg = "Domain not allowed: $domain! Allowed domains: $($config.AllowedDomains -join ', ')" >> Write-Log -Message $msg -Level 'Warning' >> throw $msg >> } >> >> Write-Log -Message "Domain allowed: $domain" >> >> # 确保输出目录存在 >> $outputDir = Split-Path $OutputPath -Parent >> if (-not (Test-Path $outputDir)) { >> New-Item -Path $outputDir -ItemType Directory -Force | Out-Null >> Write-Log -Message "Created directory: $outputDir" >> } >> >> # 执行下载 >> $curlPath = Get-CurlPath >> Write-Log -Message "Using curl: $curlPath" >> >> # 添加进度显示 >> Write-Host "Downloading $Url..." -NoNewline >> >> & $curlPath -L -o $OutputPath $Url >> >> if ($LASTEXITCODE -ne 0) { >> $msg = "Download failed! Error code: $LASTEXITCODE" >> Write-Log -Message $msg -Level 'Error' >> throw $msg >> } >> >> Write-Host " [OK]" -ForegroundColor Green >> Write-Log -Message "Download completed: $OutputPath" >> Write-Host "Download successful: $OutputPath" -ForegroundColor Green >> >> return $true >> } >> catch { >> Write-Log -Message "Download failed: $_" -Level 'Error' >> throw $_ >> } >> } >> >> Export-ModuleMember -Function Get-CurlPath, Get-CurlVersion, Invoke-SecureDownload >> Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:150 字符: 1 + Export-ModuleMember -Function Get-CurlPath, Get-CurlVersion, Invoke-S ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> # 设置UTF-8编码 >> [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 >> $OutputEncoding = [System.Text.Encoding]::UTF8 >> chcp 65001 | Out-Null >> >> # 添加模块路径 >> $modulePath = "E:\CurlTools\Modules" >> if ($env:PSModulePath -notlike "*$modulePath*") { >> $env:PSModulePath += ";$modulePath" >> } >> >> # 自动加载模块 >> try { >> Import-Module CurlTools -Force -ErrorAction Stop >> Write-Host "CurlTools module loaded successfully!" -ForegroundColor Green >> } >> catch { >> Write-Host "Failed to load CurlTools module: $_" -ForegroundColor Red >> } >> CurlTools module loaded successfully! PS C:\Users\Administrator> # 添加到模块脚本末尾 >> function Test-CurlTools { >> try { >> Write-Host "Running CurlTools self-test..." -ForegroundColor Cyan >> >> # 测试配置路径 >> $curlPath = Get-CurlPath >> Write-Host "✓ curl.exe found at: $curlPath" -ForegroundColor Green >> >> # 测试版本获取 >> $version = Get-CurlVersion >> Write-Host "✓ curl version: $version" -ForegroundColor Green >> >> # 测试域名检查 >> $testUrl = "https://example.com" >> $domain = ([System.Uri]$testUrl).Host >> Write-Host "✓ Domain extraction: $domain" -ForegroundColor Green >> >> # 测试下载 >> $testPath = "E:\CurlTools\Temp\test.html" >> if (Test-Path $testPath) { Remove-Item $testPath -Force } >> >> Invoke-SecureDownload -Url $testUrl -OutputPath $testPath >> >> if (Test-Path $testPath) { >> Write-Host "✓ Test download successful" -ForegroundColor Green >> Remove-Item $testPath -Force >> } >> >> Write-Host "All tests passed!" -ForegroundColor Green >> return $true >> } >> catch { >> Write-Host "Test failed: $_" -ForegroundColor Red >> return $false >> } >> } >> >> Export-ModuleMember -Function Test-CurlTools >> Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:39 字符: 1 + Export-ModuleMember -Function Test-CurlTools + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> # 初始化环境 >> . $PROFILE >> >> # 运行自检 >> Test-CurlTools >> >> # 下载文件 >> Invoke-SecureDownload -Url "https://example.com" -OutputPath "E:\Downloads\example.html" >> >> # 获取curl信息 >> Get-CurlPath >> Get-CurlVersion >> Running CurlTools self-test... ✓ curl.exe found at: E:\CurlTools\CurlBin\curl.exe ✓ curl version: curl 8.15.0 (x86_64-w64-mingw32) libcurl/8.15.0 LibreSSL/4.1.0 zlib/1.3.1.zlib-ng brotli/1.1.0 zstd/1.5.7 WinIDN libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.66.0 ngtcp2/1.14.0 nghttp3/1.11.0 ✓ Domain extraction: example.com Download successful: E:\CurlTools\Temp\test.html ✓ Test download successful All tests passed! True Download failed! Error code: 23 所在位置 E:\CurlTools\Modules\CurlTools\CurlTools.psm1:29 字符: 9 + throw "Download failed! Error code: $LASTEXITCODE" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Download failed! Error code: 23:String) [], RuntimeException + FullyQualifiedErrorId : Download failed! Error code: 23 PS C:\Users\Administrator> # 允许 example.com 及其所有子域名 PS C:\Users\Administrator> if ($domain -eq $allowed -or $domain.EndsWith(".$allowed")) { >> $isAllowed = $true >> break >> } PS C:\Users\Administrator> # 允许 example.com 及其所有子域名 PS C:\Users\Administrator> if ($domain -eq $allowed -or $domain.EndsWith(".$allowed")) { >> $isAllowed = $true >> break >> } PS C:\Users\Administrator> # 允许 example.com 及其所有子域名 >> if ($domain -eq $allowed -or $domain.EndsWith(".$allowed")) { >> $isAllowed = $true >> break >> } >> PS C:\Users\Administrator> # 检查配置属性是否存在 >> if (-not $config.PSObject.Properties.Name -contains 'AllowedDomains') { >> throw "Config file missing 'AllowedDomains' property" >> } >> Config file missing 'AllowedDomains' property 所在位置 行:3 字符: 5 + throw "Config file missing 'AllowedDomains' property" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Config file mis...mains' property:String) [], RuntimeException + FullyQualifiedErrorId : Config file missing 'AllowedDomains' property PS C:\Users\Administrator> Write-Log -Message "Using curl: $curlPath" >> PS C:\Users\Administrator> Write-Host "Downloading $Url..." -NoNewline >> # ...下载完成后 >> Write-Host " [OK]" -ForegroundColor Green >> Downloading ... [OK] PS C:\Users\Administrator>”

filetype

processing file: SangerRead_Report_ab1.Rmd |................................................. | 95% [unnamed-chunk-9]INFO [2025-08-11 17:21:31] * Making basecall !! INFO [2025-08-11 17:21:31] * Updating slots in 'SangerRead' instance !! output file: SangerRead_Report_ab1.knit.md "C:/PROGRA~1/Pandoc/pandoc" +RTS -K512m -RTS SangerRead_Report_ab1.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output pandoc237871d63756.html --lua-filter "C:\PROGRA~1\R\R-44~1.3\library\RMARKD~1\RMARKD~1\lua\PAGEBR~1.LUA" --lua-filter "C:\PROGRA~1\R\R-44~1.3\library\RMARKD~1\RMARKD~1\lua\LATEX-~1.LUA" --lua-filter "C:\PROGRA~1\R\R-44~1.3\library\RMARKD~1\RMARKD~1\lua\TABLE-~1.LUA" --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template "C:\PROGRA~1\R\R-44~1.3\library\RMARKD~1\rmd\h\DEFAUL~1.HTM" --no-highlight --variable highlightjs=1 --variable theme=bootstrap --mathjax --variable "mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" --include-in-header "C:\Users\ADMINI~1\AppData\Local\Temp\RtmpYBVwty\rmarkdown-str237857086851.html" [WARNING] Div at SangerRead_Report_ab1.knit.md line 153 column 1 unclosed at SangerRead_Report_ab1.knit.md line 232 column 1, closing implicitly. [WARNING] Div at SangerRead_Report_ab1.knit.md line 147 column 1 unclosed at SangerRead_Report_ab1.knit.md line 232 column 1, closing implicitly. Output created: C:/Users/Administrator/AppData/Local/Temp/RtmpYBVwty/013-G2/SangerRead_Report_ab1.html Error: 分析失败: $ operator is invalid for atomic vectors Execution halted

filetype

PS C:\Users\Administrator> # 获取当前 curl 路径 >> Get-CurlPath >> >> # 设置自定义 curl 路径 >> Set-CurlPath -Path "C:\Custom\Curl\Path" >> >> # 获取 curl 版本信息 >> Get-CurlVersion >> Get-CurlPath : 无法将“Get-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径 ,请确保路径正确,然后再试一次。 所在位置 行:2 字符: 1 + Get-CurlPath + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-CurlPath:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Set-CurlPath : 无法将“Set-CurlPath”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径 ,请确保路径正确,然后再试一次。 所在位置 行:5 字符: 1 + Set-CurlPath -Path "C:\Custom\Curl\Path" + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Set-CurlPath:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-CurlVersion : 无法将“Get-CurlVersion”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包 括路径,请确保路径正确,然后再试一次。 所在位置 行:8 字符: 1 + Get-CurlVersion + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Get-CurlVersion:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator> # 基本下载 >> Invoke-SecureDownload -Url "https://example.com/file.zip" -OutputPath "C:\Downloads\file.zip" >> >> # 带哈希验证的下载 >> $expectedHash = "2a5f3c8d9e1b4a7c6d9f0e1a2b3c4d5e6f7a8b9c0" >> Invoke-SecureDownload -Url "https://example.com/file.zip" ` >> -OutputPath "C:\Downloads\file.zip" ` >> -ExpectedHash $expectedHash ` >> -HashAlgorithm SHA256 >> Invoke-SecureDownload : 无法将“Invoke-SecureDownload”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的 拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:2 字符: 1 + Invoke-SecureDownload -Url "https://example.com/file.zip" -OutputPath ... + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-SecureDownload:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Invoke-SecureDownload : 无法将“Invoke-SecureDownload”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的 拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:6 字符: 1 + Invoke-SecureDownload -Url "https://example.com/file.zip" ` + ~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Invoke-SecureDownload:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator> CurlTools/ >> ├── CurlTools.psd1 # 模块清单 >> ├── CurlTools.psm1 # 主模块文件 >> └── en-US/ >> └── about_CurlTools.help.txt # 帮助文件 >> CurlTools/ : 无法将“CurlTools/”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请 确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + CurlTools/ + ~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (CurlTools/:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ├── : 无法将“├──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径 正确,然后再试一次。 所在位置 行:2 字符: 1 + ├── CurlTools.psd1 # 模块清单 + ~~~ + CategoryInfo : ObjectNotFound: (├──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ├── : 无法将“├──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径 正确,然后再试一次。 所在位置 行:3 字符: 1 + ├── CurlTools.psm1 # 主模块文件 + ~~~ + CategoryInfo : ObjectNotFound: (├──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException └── : 无法将“└──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径 正确,然后再试一次。 所在位置 行:4 字符: 1 + └── en-US/ + ~~~ + CategoryInfo : ObjectNotFound: (└──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException └── : 无法将“└──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径 正确,然后再试一次。 所在位置 行:5 字符: 5 + └── about_CurlTools.help.txt # 帮助文件 + ~~~ + CategoryInfo : ObjectNotFound: (└──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator> function Invoke-SecureDownload { >> param(...) >> try { >> # 核心逻辑 >> } >> catch { >> # 添加详细错误信息 >> $errorDetails = @{ >> Url = $Url >> OutputPath = $OutputPath >> Error = $_.Exception.Message >> Timestamp = Get-Date -Format o >> } >> Write-Error (ConvertTo-Json $errorDetails) >> throw >> } >> } >> 所在位置 行:2 字符: 11 + param(...) + ~ 函数参数列表中缺少“)”。 所在位置 行:1 字符: 32 + function Invoke-SecureDownload { + ~ 语句块或类型定义中缺少右“}”。 所在位置 行:2 字符: 14 + param(...) + ~ 表达式或语句中包含意外的标记“)”。 所在位置 行:17 字符: 1 + } + ~ 表达式或语句中包含意外的标记“}”。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : MissingEndParenthesisInFunctionParameterList PS C:\Users\Administrator> # 使用 .NET 方法替代部分 PowerShell cmdlet 提高性能 >> $fileStream = [System.IO.File]::OpenWrite($OutputPath) >> $webClient = [System.Net.WebClient]::new() >> $webClient.DownloadFile($Url, $fileStream) >> $fileStream.Close() >> 使用“1”个参数调用“OpenWrite”时发生异常:“空路径名是非法的。” 所在位置 行:2 字符: 1 + $fileStream = [System.IO.File]::OpenWrite($OutputPath) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentException 使用“2”个参数调用“DownloadFile”时发生异常:“值不能为 null。 参数名: address” 所在位置 行:4 字符: 1 + $webClient.DownloadFile($Url, $fileStream) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : ArgumentNullException 不能对 Null 值表达式调用方法。 所在位置 行:5 字符: 1 + $fileStream.Close() + ~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [],RuntimeException + FullyQualifiedErrorId : InvokeMethodOnNull PS C:\Users\Administrator> function Update-CurlTools { >> param([switch]$Force) >> >> $updateUrl = "https://api.github.com/repos/yourname/curltools/releases/latest" >> $response = Invoke-RestMethod $updateUrl >> $latestVersion = [Version]$response.tag_name >> $currentVersion = [Version](Get-Module CurlTools).Version >> >> if ($latestVersion -gt $currentVersion -or $Force) { >> Write-Host "更新模块到版本 $latestVersion" >> $installScript = Join-Path $env:TEMP "install.ps1" >> Invoke-SecureDownload -Url $response.assets[0].browser_download_url ` >> -OutputPath $installScript >> & $installScript >> } >> } >> PS C:\Users\Administrator> function Update-CurlTools { >> param([switch]$Force) >> >> $updateUrl = "https://api.github.com/repos/yourname/curltools/releases/latest" >> $response = Invoke-RestMethod $updateUrl >> $latestVersion = [Version]$response.tag_name >> $currentVersion = [Version](Get-Module CurlTools).Version >> >> if ($latestVersion -gt $currentVersion -or $Force) { >> Write-Host "更新模块到版本 $latestVersion" >> $installScript = Join-Path $env:TEMP "install.ps1" >> Invoke-SecureDownload -Url $response.assets[0].browser_download_url ` >> -OutputPath $installScript >> & $installScript >> } >> } >> PS C:\Users\Administrator> # 使用 PlatyPS 生成 Markdown 文档 >> Install-Module PlatyPS -Force >> New-MarkdownHelp -Module CurlTools -OutputFolder docs -Force >> 需要使用 NuGet 提供程序来继续操作 PowerShellGet 需要使用 NuGet 提供程序“2.8.5.201”或更高版本来与基于 NuGet 的存储库交互。必须在“C:\Program Files\PackageManagement\ProviderAssemblies”或“C:\Users\Administrator\AppData\Local\PackageManagement\ProviderAssembli es”中提供 NuGet 提供程序。也可以通过运行 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force' 安装 NuGet 提供程序。是否要让 PowerShellGet 立即安装并导入 NuGet 提供程序? [Y] 是(Y) [N] 否(N) [S] 暂停(S) [?] 帮助 (默认值为“Y”):

filetype

PS C:\Users\Administrator> function Get-CurlPath { >> # 从配置获取curl路径 >> $configPath = "E:\CurlTools\Config\config.json" >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> $curlPath = Join-Path $config.CurlPath "curl.exe" >> >> if (-not (Test-Path $curlPath)) { >> throw "curl.exe not found! Check path: $curlPath" >> } >> >> return $curlPath >> } >> >> function Get-CurlVersion { >> # 获取curl版本信息 >> $curlPath = Get-CurlPath >> $version = & $curlPath --version | Select-Object -First 1 >> return $version >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath >> ) >> >> # 检查域名是否允许 >> $domain = ([System.Uri]$Url).Host >> $configPath = "E:\CurlTools\Config\config.json" >> >> if (-not (Test-Path $configPath)) { >> throw "Config file not found: $configPath" >> } >> >> $config = Get-Content $configPath | ConvertFrom-Json >> >> # 增强域名检查逻辑 >> if (-not $config.AllowedDomains) { >> throw "No allowed domains configured!" >> } >> >> if ($domain -notin $config.AllowedDomains) { >> throw "Domain not allowed: $domain! Allowed domains: $($config.AllowedDomains -join ', ')" >> } >> >> # 确保输出目录存在 >> $outputDir = Split-Path $OutputPath -Parent >> if (-not (Test-Path $outputDir)) { >> New-Item -Path $outputDir -ItemType Directory -Force | Out-Null >> } >> >> # 执行下载 >> $curlPath = Get-CurlPath >> & $curlPath -L -o $OutputPath $Url >> >> if ($LASTEXITCODE -ne 0) { >> throw "Download failed! Error code: $LASTEXITCODE" >> } >> >> Write-Host "Download successful: $OutputPath" -ForegroundColor Green >> } >> PS C:\Users\Administrator> { >> "CurlPath": "E:\\CurlTools\\CurlBin", >> "AllowedDomains": [ >> "example.com", >> "github.com", >> "microsoft.com" >> ] >> } >> 所在位置 行:2 字符: 15 + "CurlPath": "E:\\CurlTools\\CurlBin", + ~ 表达式或语句中包含意外的标记“:”。 + CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException + FullyQualifiedErrorId : UnexpectedToken PS C:\Users\Administrator> # 设置UTF-8编码 >> [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 >> $OutputEncoding = [System.Text.Encoding]::UTF8 >> chcp 65001 | Out-Null >> >> # 添加模块路径 >> $modulePath = "E:\CurlTools\Modules" >> if ($env:PSModulePath -notlike "*$modulePath*") { >> $env:PSModulePath += ";$modulePath" >> } >> >> # 自动加载模块 >> Import-Module CurlTools -Force -ErrorAction SilentlyContinue >> PS C:\Users\Administrator> graph TD >> A[PowerShell会话] --> B[$PROFILE] >> B --> C[自动加载模块] >> C --> D[CurlTools模块] >> D --> E[Get-CurlPath] >> D --> F[Get-CurlVersion] >> D --> G[Invoke-SecureDownload] >> A --> H[配置文件] >> H --> I[config.json] >> H --> J[日志文件] >> G --> K[域名检查] >> G --> L[安全下载] >> K --> M[AllowedDomains验证] >> L --> N[curl.exe执行] >> graph : 无法将“graph”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + graph TD + ~~~~~ + CategoryInfo : ObjectNotFound: (graph:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException A[PowerShell会话] : 无法将“A[PowerShell会话]”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:2 字符: 5 + A[PowerShell会话] --> B[$PROFILE] + ~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (A[PowerShell会话]:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException B : 无法将“B”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:3 字符: 5 + B --> C[自动加载模块] + ~ + CategoryInfo : ObjectNotFound: (B:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException C : 无法将“C”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:4 字符: 5 + C --> D[CurlTools模块] + ~ + CategoryInfo : ObjectNotFound: (C:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:5 字符: 5 + D --> E[Get-CurlPath] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:6 字符: 5 + D --> F[Get-CurlVersion] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException D : 无法将“D”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:7 字符: 5 + D --> G[Invoke-SecureDownload] + ~ + CategoryInfo : ObjectNotFound: (D:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException A : 无法将“A”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:8 字符: 5 + A --> H[配置文件] + ~ + CategoryInfo : ObjectNotFound: (A:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException Get-History : 无法绑定参数“Count”。无法将值“I[config.json]”转换为类型“System.Int32”。错误:“输入字符串的格式不正确。” 所在位置 行:9 字符: 11 + H --> I[config.json] + ~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-History],ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetHistoryCommand Get-History : 无法绑定参数“Count”。无法将值“J[日志文件]”转换为类型“System.Int32”。错误:“输入字符串的格式不正确。 ” 所在位置 行:10 字符: 11 + H --> J[日志文件] + ~~~~~~~ + CategoryInfo : InvalidArgument: (:) [Get-History],ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetHistoryCommand G : 无法将“G”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:11 字符: 5 + G --> K[域名检查] + ~ + CategoryInfo : ObjectNotFound: (G:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException G : 无法将“G”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:12 字符: 5 + G --> L[安全下载] + ~ + CategoryInfo : ObjectNotFound: (G:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException K : 无法将“K”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:13 字符: 5 + K --> M[AllowedDomains验证] + ~ + CategoryInfo : ObjectNotFound: (K:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException L : 无法将“L”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:14 字符: 5 + L --> N[curl.exe执行] + ~ + CategoryInfo : ObjectNotFound: (L:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator> # 在模块顶部添加日志函数 >> function Write-Log { >> param( >> [string]$Message, >> [ValidateSet('Info','Warning','Error')] >> [string]$Level = 'Info' >> ) >> >> $logPath = "E:\CurlTools\Logs\curl_tools_$(Get-Date -Format 'yyyyMMdd').log" >> $logEntry = "[$(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')] [$Level] $Message" >> >> Add-Content -Path $logPath -Value $logEntry >> } >> >> # 在关键位置添加日志记录 >> function Invoke-SecureDownload { >> # ... 其他代码 ... >> >> Write-Log -Message "Starting download: $Url" -Level 'Info' >> >> try { >> # ... 域名检查 ... >> Write-Log -Message "Domain allowed: $domain" >> >> # ... 执行下载 ... >> Write-Log -Message "Download completed: $OutputPath" >> } >> catch { >> Write-Log -Message "Download failed: $_" -Level 'Error' >> throw $_ >> } >> } >> PS C:\Users\Administrator> $url = "https://subdomain.example.com/path" >> $domain = ([System.Uri]$url).Host # 返回 "subdomain.example.com" >> PS C:\Users\Administrator> if (-not (Test-Path $config.CurlPath)) { >> throw "CurlPath directory not found: $($config.CurlPath)" >> } >> Test-Path : 无法将参数绑定到参数“Path”,因为该参数是空值。 所在位置 行:1 字符: 21 + if (-not (Test-Path $config.CurlPath)) { + ~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (:) [Test-Path],ParameterBindingValidationException + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.TestPathCom mand PS C:\Users\Administrator>

filetype

pip3 install . Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Processing /home/ubuntu/large_models/speech_pkg Preparing metadata (setup.py) ... done Building wheels for collected packages: speech DEPRECATION: Building 'speech' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'speech'. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for speech (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [322 lines of output] running bdist_wheel running build running build_py creating build creating build/lib creating build/lib/speech copying speech/awake.py -> build/lib/speech copying speech/__init__.py -> build/lib/speech running egg_info writing speech.egg-info/PKG-INFO writing dependency_links to speech.egg-info/dependency_links.txt writing top-level names to speech.egg-info/top_level.txt reading manifest file 'speech.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'speech.egg-info/SOURCES.txt' /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.jetson_nano' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.jetson_nano' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.jetson_nano' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.jetson_nano' to be distributed and are already explicitly excluding 'speech.jetson_nano' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.jetson_orin' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.jetson_orin' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.jetson_orin' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.jetson_orin' to be distributed and are already explicitly excluding 'speech.jetson_orin' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.resources' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.resources' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.resources' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.resources' to be distributed and are already explicitly excluding 'speech.resources' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.rpi5' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.rpi5' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.rpi5' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.rpi5' to be distributed and are already explicitly excluding 'speech.rpi5' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.rpi5_docker' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.rpi5_docker' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.rpi5_docker' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.rpi5_docker' to be distributed and are already explicitly excluding 'speech.rpi5_docker' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) copying speech/speech.so -> build/lib/speech creating build/lib/speech/jetson_nano copying speech/jetson_nano/py3.6 -> build/lib/speech/jetson_nano copying speech/jetson_nano/speech.so -> build/lib/speech/jetson_nano creating build/lib/speech/jetson_orin copying speech/jetson_orin/py3.10 -> build/lib/speech/jetson_orin copying speech/jetson_orin/speech.so -> build/lib/speech/jetson_orin creating build/lib/speech/resources copying speech/resources/_detect_jetson_nano.so -> build/lib/speech/resources copying speech/resources/_detect_jetson_orin.so -> build/lib/speech/resources copying speech/resources/_detect_rpi5.so -> build/lib/speech/resources copying speech/resources/_detect_rpi5_docker_ubuntu20_04.so -> build/lib/speech/resources copying speech/resources/common.res -> build/lib/speech/resources copying speech/resources/detect_jetson_nano.so -> build/lib/speech/resources copying speech/resources/detect_jetson_orin.so -> build/lib/speech/resources copying speech/resources/detect_rpi5.so -> build/lib/speech/resources copying speech/resources/detect_rpi5_docker_ubuntu20_04.so -> build/lib/speech/resources copying speech/resources/vad.jit -> build/lib/speech/resources creating build/lib/speech/rpi5 copying speech/rpi5/py3.11 -> build/lib/speech/rpi5 copying speech/rpi5/speech.so -> build/lib/speech/rpi5 creating build/lib/speech/rpi5_docker copying speech/rpi5_docker/py3.8 -> build/lib/speech/rpi5_docker copying speech/rpi5_docker/speech.so -> build/lib/speech/rpi5_docker copying speech/awake.py -> build/lib/speech copying speech/__init__.py -> build/lib/speech /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() installing to build/bdist.linux-aarch64/wheel running install running install_lib creating build/bdist.linux-aarch64 creating build/bdist.linux-aarch64/wheel creating build/bdist.linux-aarch64/wheel/speech copying build/lib/speech/awake.py -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/jetson_orin copying build/lib/speech/jetson_orin/speech.so -> build/bdist.linux-aarch64/wheel/speech/jetson_orin copying build/lib/speech/jetson_orin/py3.10 -> build/bdist.linux-aarch64/wheel/speech/jetson_orin creating build/bdist.linux-aarch64/wheel/speech/rpi5_docker copying build/lib/speech/rpi5_docker/speech.so -> build/bdist.linux-aarch64/wheel/speech/rpi5_docker copying build/lib/speech/rpi5_docker/py3.8 -> build/bdist.linux-aarch64/wheel/speech/rpi5_docker creating build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/rpi5/speech.so -> build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/rpi5/py3.11 -> build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/speech.so -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/jetson_nano/py3.6 -> build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/jetson_nano/speech.so -> build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/__init__.py -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_rpi5.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/common.res -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_jetson_nano.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_jetson_orin.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_jetson_nano.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_rpi5_docker_ubuntu20_04.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_rpi5.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/vad.jit -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_jetson_orin.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_rpi5_docker_ubuntu20_04.so -> build/bdist.linux-aarch64/wheel/speech/resources running install_egg_info Copying speech.egg-info to build/bdist.linux-aarch64/wheel/speech-1.0-py3.10.egg-info running install_scripts creating build/bdist.linux-aarch64/wheel/speech-1.0.dist-info/WHEEL creating '/tmp/pip-wheel-4gy84oln/speech-1.0-py3-none-any.whl' and adding 'build/bdist.linux-aarch64/wheel' to it Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/home/ubuntu/large_models/speech_pkg/setup.py", line 3, in <module> setup( File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup return distutils.core.setup(**attrs) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 184, in setup return run_commands(dist) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 200, in run_commands dist.run_commands() File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/dist.py", line 968, in run_command super().run_command(command) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 361, in run wf.write_files(archive_root) File "/usr/lib/python3/dist-packages/wheel/wheelfile.py", line 136, in write_files self.write(path, arcname) File "/usr/lib/python3/dist-packages/wheel/wheelfile.py", line 147, in write zinfo = ZipInfo(arcname or filename, date_time=get_zipinfo_datetime(st.st_mtime)) File "/usr/lib/python3.10/zipfile.py", line 366, in __init__ raise ValueError('ZIP does not support timestamps before 1980') ValueError: ZIP does not support timestamps before 1980 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for speech Running setup.py clean for speech Failed to build speech ERROR: Failed to build installable wheels for some pyproject.toml based projects (speech) > cat ~/large_models/speech_pkg/pyproject.toml cat: /home/ubuntu/large_models/speech_pkg/pyproject.toml: No such file or directory > pip3 install . Defaulting to user installation because normal site-packages is not writeable Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Processing /home/ubuntu/large_models/speech_pkg Preparing metadata (setup.py) ... done Building wheels for collected packages: speech DEPRECATION: Building 'speech' using the legacy setup.py bdist_wheel mechanism, which will be removed in a future version. pip 25.3 will enforce this behaviour change. A possible replacement is to use the standardized build interface by setting the `--use-pep517` option, (possibly combined with `--no-build-isolation`), or adding a `pyproject.toml` file to the source tree of 'speech'. Discussion can be found at https://github.com/pypa/pip/issues/6334 Building wheel for speech (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [322 lines of output] running bdist_wheel running build running build_py creating build creating build/lib creating build/lib/speech copying speech/awake.py -> build/lib/speech copying speech/__init__.py -> build/lib/speech running egg_info writing speech.egg-info/PKG-INFO writing dependency_links to speech.egg-info/dependency_links.txt writing top-level names to speech.egg-info/top_level.txt reading manifest file 'speech.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'speech.egg-info/SOURCES.txt' /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.jetson_nano' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.jetson_nano' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.jetson_nano' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.jetson_nano' to be distributed and are already explicitly excluding 'speech.jetson_nano' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.jetson_orin' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.jetson_orin' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.jetson_orin' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.jetson_orin' to be distributed and are already explicitly excluding 'speech.jetson_orin' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.resources' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.resources' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.resources' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.resources' to be distributed and are already explicitly excluding 'speech.resources' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.rpi5' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.rpi5' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.rpi5' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.rpi5' to be distributed and are already explicitly excluding 'speech.rpi5' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/command/build_py.py:207: _Warning: Package 'speech.rpi5_docker' is absent from the `packages` configuration. !! ******************************************************************************** ############################ # Package would be ignored # ############################ Python recognizes 'speech.rpi5_docker' as an importable package[^1], but it is absent from setuptools' `packages` configuration. This leads to an ambiguous overall configuration. If you want to distribute this package, please make sure that 'speech.rpi5_docker' is explicitly added to the `packages` configuration field. Alternatively, you can also rely on setuptools' discovery methods (for example by using `find_namespace_packages(...)`/`find_namespace:` instead of `find_packages(...)`/`find:`). You can read more about "package discovery" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/package_discovery.html If you don't want 'speech.rpi5_docker' to be distributed and are already explicitly excluding 'speech.rpi5_docker' via `find_namespace_packages(...)/find_namespace` or `find_packages(...)/find`, you can try to use `exclude_package_data`, or `include-package-data=False` in combination with a more fine grained `package-data` configuration. You can read more about "package data files" on setuptools documentation page: - https://setuptools.pypa.io/en/latest/userguide/datafiles.html [^1]: For Python, any directory (with suitable naming) can be imported, even if it does not contain any `.py` files. On the other hand, currently there is no concept of package data directory, all directories are treated like packages. ******************************************************************************** !! check.warn(importable) copying speech/speech.so -> build/lib/speech creating build/lib/speech/jetson_nano copying speech/jetson_nano/py3.6 -> build/lib/speech/jetson_nano copying speech/jetson_nano/speech.so -> build/lib/speech/jetson_nano creating build/lib/speech/jetson_orin copying speech/jetson_orin/py3.10 -> build/lib/speech/jetson_orin copying speech/jetson_orin/speech.so -> build/lib/speech/jetson_orin creating build/lib/speech/resources copying speech/resources/_detect_jetson_nano.so -> build/lib/speech/resources copying speech/resources/_detect_jetson_orin.so -> build/lib/speech/resources copying speech/resources/_detect_rpi5.so -> build/lib/speech/resources copying speech/resources/_detect_rpi5_docker_ubuntu20_04.so -> build/lib/speech/resources copying speech/resources/common.res -> build/lib/speech/resources copying speech/resources/detect_jetson_nano.so -> build/lib/speech/resources copying speech/resources/detect_jetson_orin.so -> build/lib/speech/resources copying speech/resources/detect_rpi5.so -> build/lib/speech/resources copying speech/resources/detect_rpi5_docker_ubuntu20_04.so -> build/lib/speech/resources copying speech/resources/vad.jit -> build/lib/speech/resources creating build/lib/speech/rpi5 copying speech/rpi5/py3.11 -> build/lib/speech/rpi5 copying speech/rpi5/speech.so -> build/lib/speech/rpi5 creating build/lib/speech/rpi5_docker copying speech/rpi5_docker/py3.8 -> build/lib/speech/rpi5_docker copying speech/rpi5_docker/speech.so -> build/lib/speech/rpi5_docker copying speech/awake.py -> build/lib/speech copying speech/__init__.py -> build/lib/speech /home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !! ******************************************************************************** Please avoid running ``setup.py`` directly. Instead, use pypa/build, pypa/installer or other standards-based tools. See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details. ******************************************************************************** !! self.initialize_options() installing to build/bdist.linux-aarch64/wheel running install running install_lib creating build/bdist.linux-aarch64 creating build/bdist.linux-aarch64/wheel creating build/bdist.linux-aarch64/wheel/speech copying build/lib/speech/awake.py -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/jetson_orin copying build/lib/speech/jetson_orin/speech.so -> build/bdist.linux-aarch64/wheel/speech/jetson_orin copying build/lib/speech/jetson_orin/py3.10 -> build/bdist.linux-aarch64/wheel/speech/jetson_orin creating build/bdist.linux-aarch64/wheel/speech/rpi5_docker copying build/lib/speech/rpi5_docker/speech.so -> build/bdist.linux-aarch64/wheel/speech/rpi5_docker copying build/lib/speech/rpi5_docker/py3.8 -> build/bdist.linux-aarch64/wheel/speech/rpi5_docker creating build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/rpi5/speech.so -> build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/rpi5/py3.11 -> build/bdist.linux-aarch64/wheel/speech/rpi5 copying build/lib/speech/speech.so -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/jetson_nano/py3.6 -> build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/jetson_nano/speech.so -> build/bdist.linux-aarch64/wheel/speech/jetson_nano copying build/lib/speech/__init__.py -> build/bdist.linux-aarch64/wheel/speech creating build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_rpi5.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/common.res -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_jetson_nano.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_jetson_orin.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_jetson_nano.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_rpi5_docker_ubuntu20_04.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/detect_rpi5.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/vad.jit -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_jetson_orin.so -> build/bdist.linux-aarch64/wheel/speech/resources copying build/lib/speech/resources/_detect_rpi5_docker_ubuntu20_04.so -> build/bdist.linux-aarch64/wheel/speech/resources running install_egg_info Copying speech.egg-info to build/bdist.linux-aarch64/wheel/speech-1.0-py3.10.egg-info running install_scripts creating build/bdist.linux-aarch64/wheel/speech-1.0.dist-info/WHEEL creating '/tmp/pip-wheel-dpii6adm/speech-1.0-py3-none-any.whl' and adding 'build/bdist.linux-aarch64/wheel' to it Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/home/ubuntu/large_models/speech_pkg/setup.py", line 3, in <module> setup( File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/__init__.py", line 103, in setup return distutils.core.setup(**attrs) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 184, in setup return run_commands(dist) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 200, in run_commands dist.run_commands() File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/dist.py", line 968, in run_command super().run_command(command) File "/home/ubuntu/.local/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/usr/lib/python3/dist-packages/wheel/bdist_wheel.py", line 361, in run wf.write_files(archive_root) File "/usr/lib/python3/dist-packages/wheel/wheelfile.py", line 136, in write_files self.write(path, arcname) File "/usr/lib/python3/dist-packages/wheel/wheelfile.py", line 147, in write zinfo = ZipInfo(arcname or filename, date_time=get_zipinfo_datetime(st.st_mtime)) File "/usr/lib/python3.10/zipfile.py", line 366, in __init__ raise ValueError('ZIP does not support timestamps before 1980') ValueError: ZIP does not support timestamps before 1980 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for speech Running setup.py clean for speech Failed to build speech ERROR: Failed to build installable wheels for some pyproject.toml based projects (speech)

filetype

PS C:\Users\Administrator> # CurlTools.psm1 >> # ============== >> # 修复函数导出问题的模块代码 >> >> # 模块初始化块 >> $script:Config = $null >> $script:CurlPath = $null >> $script:ConfigDir = $null >> $script:ConfigPath = $null >> $script:ModuleInitialized = $false >> >> # 检测操作系统 >> function Get-Platform { >> if ($PSVersionTable.PSEdition -eq "Core") { >> if ($IsWindows) { "Windows" } >> elseif ($IsLinux) { "Linux" } >> elseif ($IsMacOS) { "macOS" } >> } else { >> if ($env:OS -like "Windows*") { "Windows" } >> elseif (Test-Path "/etc/os-release") { "Linux" } >> else { "macOS" } >> } >> } >> >> # 获取配置目录 >> function Get-ConfigDir { >> $platform = Get-Platform >> switch ($platform) { >> "Linux" { "$HOME/.config/curltools" } >> "macOS" { "$HOME/Library/Application Support/CurlTools" } >> default { "$env:APPDATA\CurlTools" } >> } >> } >> >> # 核心初始化函数 >> function Initialize-Module { >> try { >> # 设置配置目录 >> $script:ConfigDir = Get-ConfigDir >> if (-not (Test-Path $script:ConfigDir)) { >> New-Item -ItemType Directory -Path $script:ConfigDir -Force | Out-Null >> } >> $script:ConfigPath = Join-Path $script:ConfigDir "config.json" >> >> # 加载或创建配置 >> if (Test-Path $script:ConfigPath) { >> $script:Config = Get-Content $script:ConfigPath | ConvertFrom-Json >> } >> >> if (-not $script:Config) { >> $script:Config = [PSCustomObject]@{ >> CurlPath = $null >> LastUpdate = (Get-Date).ToString("o") >> AutoUpdate = $true >> } >> } >> >> # 查找或安装curl >> if (-not $script:Config.CurlPath -or -not (Test-Path $script:Config.CurlPath)) { >> $script:Config.CurlPath = Find-CurlPath >> } >> >> # 保存配置 >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> $script:CurlPath = $script:Config.CurlPath >> $script:ModuleInitialized = $true >> >> return $true >> } catch { >> Write-Warning "模块初始化失败: $_" >> return $false >> } >> } >> >> # 查找curl路径 >> function Find-CurlPath { >> $platform = Get-Platform >> $exeName = if ($platform -eq "Windows") { "curl.exe" } else { "curl" } >> >> # 检查系统PATH >> $pathCurl = Get-Command $exeName -ErrorAction SilentlyContinue >> if ($pathCurl) { >> return $pathCurl.Source | Split-Path >> } >> >> # 平台特定路径 >> $searchPaths = switch ($platform) { >> "Windows" { >> @( >> "C:\Windows\System32", >> "C:\Program Files\curl\bin", >> "${env:ProgramFiles}\Git\usr\bin" >> ) >> } >> "Linux" { @("/usr/bin", "/usr/local/bin") } >> "macOS" { @("/usr/local/bin", "/opt/homebrew/bin") } >> } >> >> foreach ($path in $searchPaths) { >> $fullPath = Join-Path $path $exeName >> if (Test-Path $fullPath) { >> return $path >> } >> } >> >> # 终极方案:自动安装 >> return Install-Curl >> } >> >> # curl安装函数 >> function Install-Curl { >> $platform = Get-Platform >> try { >> if ($platform -eq "Windows") { >> $tempDir = [System.IO.Path]::GetTempPath() >> $curlZip = Join-Path $tempDir "curl.zip" >> $curlUrl = "https://curl.se/windows/dl-8.8.0_5/curl-8.8.0_5-win64-mingw.zip" >> >> # 使用安全下载函数 >> Invoke-SecureDownload -Url $curlUrl -OutputPath $curlZip >> >> Expand-Archive $curlZip -DestinationPath $tempDir -Force >> return Join-Path $tempDir "curl-8.8.0_5-win64-mingw\bin" >> } >> else { >> if ($platform -eq "Linux") { >> if (Get-Command apt -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "update" >> Start-Process -Wait -FilePath "sudo" -ArgumentList "apt", "install", "-y", "curl" >> } elseif (Get-Command yum -ErrorAction SilentlyContinue) { >> Start-Process -Wait -FilePath "sudo" -ArgumentList "yum", "install", "-y", "curl" >> } >> return "/usr/bin" >> } >> else { >> if (-not (Get-Command brew -ErrorAction SilentlyContinue)) { >> # 使用安全下载安装Homebrew >> $installScript = Join-Path $env:TEMP "brew_install.sh" >> Invoke-SecureDownload -Url "https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh" -OutputPath $installScript >> & "/bin/bash" $installScript >> } >> Start-Process -Wait -FilePath "brew" -ArgumentList "install", "curl" >> return "/usr/local/bin" >> } >> } >> } catch { >> throw "无法自动安装curl: $_" >> } >> } >> >> # ========== 公共函数 ========== >> function Get-CurlPath { >> Ensure-ModuleInitialized >> return $script:CurlPath >> } >> >> function Set-CurlPath { >> param( >> [Parameter(Mandatory=$true)] >> [ValidateScript({Test-Path $_})] >> [string]$Path >> ) >> >> Ensure-ModuleInitialized >> $script:CurlPath = $Path >> $script:Config.CurlPath = $Path >> $script:Config | ConvertTo-Json | Set-Content $script:ConfigPath -Force >> Write-Host "已设置curl路径: $Path" -ForegroundColor Green >> } >> >> function Get-CurlVersion { >> Ensure-ModuleInitialized >> $exe = if ((Get-Platform) -eq "Windows") { "curl.exe" } else { "curl" } >> $curlExe = Join-Path $script:CurlPath $exe >> & $curlExe --version | Select-Object -First 1 >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath, >> >> [string]$ExpectedHash, >> [string]$HashAlgorithm = "SHA256" >> ) >> >> try { >> Write-Verbose "下载文件: $Url" >> $ProgressPreference = 'SilentlyContinue' >> >> # 创建输出目录(如果不存在) >> $outputDir = [System.IO.Path]::GetDirectoryName($OutputPath) >> if (-not [string]::IsNullOrWhiteSpace($outputDir) -and -not (Test-Path $outputDir)) { >> New-Item -ItemType Directory -Path $outputDir -Force | Out-Null >> } >> >> # 下载文件 >> Invoke-WebRequest -Uri $Url -OutFile $OutputPath -UseBasicParsing -ErrorAction Stop >> >> # 验证文件是否成功下载 >> if (-not (Test-Path $OutputPath)) { >> throw "文件下载后未找到: $OutputPath" >> } >> >> # 验证哈希(如果提供) >> if (-not [string]::IsNullOrWhiteSpace($ExpectedHash)) { >> $actualHash = (Get-FileHash -Path $OutputPath -Algorithm $HashAlgorithm).Hash >> if ($actualHash -ne $ExpectedHash) { >> Remove-Item -Path $OutputPath -Force >> throw "文件哈希不匹配! 期望: $ExpectedHash, 实际: $actualHash" >> } >> } >> >> return $OutputPath >> } catch { >> # 清理部分下载的文件 >> if (Test-Path $OutputPath) { >> Remove-Item -Path $OutputPath -Force -ErrorAction SilentlyContinue >> } >> throw "下载失败: $($_.Exception.Message)" >> } >> } >> >> # ========== 辅助函数 ========== >> function Ensure-ModuleInitialized { >> if (-not $script:ModuleInitialized) { >> if (-not (Initialize-Module)) { >> throw "模块未正确初始化" >> } >> } >> } >> >> # ========== 模块初始化 ========== >> # 尝试初始化但不强制 >> try { >> Initialize-Module | Out-Null >> Write-Host "CurlTools 模块初始化成功" -ForegroundColor Green >> } catch { >> Write-Warning "模块初始化错误: $_" >> } >> >> # ========== 函数导出 ========== >> # 显式导出公共函数 >> Export-ModuleMember -Function Get-CurlPath, Set-CurlPath, Get-CurlVersion, Invoke-SecureDownload >> CurlTools 模块初始化成功 Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:247 字符: 1 + Export-ModuleMember -Function Get-CurlPath, Set-CurlPath, Get-CurlVer ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> $moduleDir = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\CurlTools" >> $modulePath = "$moduleDir\CurlTools.psm1" >> >> # 保存修复后的模块代码 >> Set-Content -Path $modulePath -Value $fixedModuleCode -Force >> PS C:\Users\Administrator> $manifest = @" >> @{ >> ModuleVersion = '1.2.0' >> RootModule = 'CurlTools.psm1' >> FunctionsToExport = @( >> 'Get-CurlPath', >> 'Set-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> CompatiblePSEditions = @('Desktop', 'Core') >> GUID = 'c0d1b1e1-1a2b-4c3d-8e4f-9a0b1c2d3e4f' >> Author = 'Your Name' >> Description = 'Powerful curl tools for PowerShell' >> } >> "@ >> >> Set-Content -Path "$moduleDir\CurlTools.psd1" -Value $manifest >> PS C:\Users\Administrator> PS C:\Users\Administrator> # 强制重新加载模块 >> Remove-Module CurlTools -ErrorAction SilentlyContinue >> Import-Module CurlTools -Force -Verbose >> >> # 验证函数是否可用 >> Get-Command -Module CurlTools >> >> # 测试所有功能 >> $curlPath = Get-CurlPath >> $curlVersion = Get-CurlVersion >> Write-Host "Curl 路径: $curlPath" -ForegroundColor Green >> Write-Host "Curl 版本: $curlVersion" -ForegroundColor Green >> >> # 测试下载功能 >> $testUrl = "https://raw.githubusercontent.com/PowerShell/PowerShell/master/README.md" >> $outputPath = "$env:TEMP\PowerShell_README.md" >> Invoke-SecureDownload -Url $testUrl -OutputPath $outputPath >> 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psd1”加载模块。 详细信息: 正在从路径“C:\Users\Administrator\Documents\WindowsPowerShell\Modules\CurlTools\CurlTools.psm1”加载模块。 Curl 路径: E:\curl-8.15.0_4-win64-mingw\bin Curl 版本: curl 8.15.0 (x86_64-w64-mingw32) libcurl/8.15.0 LibreSSL/4.1.0 zlib/1.3.1.zlib-ng brotli/1.1.0 zstd/1.5.7 WinIDN libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.66.0 ngtcp2/1.14.0 nghttp3/1.11.0 E:\ai_temp\PowerShell_README.md PS C:\Users\Administrator>

filetype

import streamlit as st import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns from pyspark.sql import SparkSession from pyspark.ml.feature import VectorAssembler, StringIndexer, OneHotEncoder from pyspark.ml import Pipeline from pyspark.ml.classification import LogisticRegression, DecisionTreeClassifier, RandomForestClassifier from pyspark.ml.evaluation import BinaryClassificationEvaluator, MulticlassClassificationEvaluator import os import time import warnings import tempfile import subprocess import sys import shutil # 忽略警告 warnings.filterwarnings("ignore") # 设置中文字体 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False # 页面设置 st.set_page_config( page_title="精准营销系统", page_icon="📊", layout="wide", initial_sidebar_state="expanded" ) # 自定义CSS样式 st.markdown(""" <style> .stApp { background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); font-family: 'Helvetica Neue', Arial, sans-serif; } .header { background: linear-gradient(90deg, #1a237e 0%, #283593 100%); color: white; padding: 1.5rem; border-radius: 0.75rem; box-shadow: 0 4px 12px rgba(0,0,0,0.1); margin-bottom: 2rem; } .card { background: white; border-radius: 0.75rem; padding: 1rem; margin-bottom: 1.5rem; box-shadow: 0 4px 12极 transition: transform 0.3s ease; } .card:hover { transform: translateY(-5px); box-shadow: 0 6px 16px rgba(0,0,0,0.12); } .stButton button { background: linear-gradient(90deg, #3949ab 0%, #1a237e 100%) !important; color: white !important; border: none !important; border-radius: 0.5rem; padding: 0.75rem 1.5rem; font-size: 1rem; font-weight: 600; transition: all 0.3s ease; width: 100%; } .stButton button:hover { transform: scale(1.05); box-shadow: 0 4px 8px rgba(57, 73, 171, 0.4); } .feature-box { background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%); border-radius: 0.75rem; padding: 极.5rem; margin-bottom: 1.5rem; } .result-box { background: linear-gradient(135deg, #e8f5e9 0%, #c8e6c9 100%); border-radius: 0.75rem; padding: 1.5rem; margin-top: 1.5rem; } .model-box { background: linear-gradient(135deg, #fff3e0 0%, #ffe0b2 100%); border-radius: 0.75rem; padding: 1.5rem; margin-top: 1.5rem; } .stProgress > div > div > div { background: linear-gradient(90deg, #2ecc71 0%, #27ae60 100%) !important; } .metric-card { background: white; border-radius: 0.75rem; padding: 1rem; text-align: center; box-shadow: 0 4px 8px rgba(0,0,0,0.06); } .metric-value { font-size: 1.8rem; font-weight: 700; color: #1a237e; } .metric-label { font-size: 0.9rem; color: #5c6bc0; margin-top: 0.5rem; } .highlight { background: linear-gradient(90deg, #ffeb3b 0%, #fbc02d 100%); padding: 0.2rem 0.5rem; border-radius: 0.25rem; font-weight: 600; } .stDataFrame { border-radius: 0.75rem; box-shadow: 0 4px 8px rgba(0,0,0,0.06); } .convert-high { background-color: #c8e6c9 !important; color: #388e3c !important; font-weight: 700; } .convert-low { background-color: #ffcdd2 !important; color: #c62828 !important; font-weight: 600; } .java-success { background-color: #d4edda; border-left: 4px solid #28a745; padding: 1rem; margin-bottom: 1.5rem; border-radius: 0 0.25rem 0.25rem 0; } </style> """, unsafe_allow_html=True) # 创建优化的Spark会话 def create_spark_session(): """创建优化的Spark会话,使用高效的配置参数""" try: # 基础配置 - 优化资源使用 builder = SparkSession.builder \ .appName("TelecomPrecisionMarketing") \ .config("spark.driver.memory", "1g") \ .config("spark.executor.memory", "1g") \ .config("spark.sql.shuffle.partitions", "4") \ .config("spark.network.timeout", "800s") \ .config("spark.executor.heartbeatInterval", "60s") \ .config("spark.sql.legacy.allowUntypedScalaUDF", "true") \ .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer") \ .config("spark.kryoserializer.buffer.max", "128m") \ .config("spark.driver.maxResultSize", "1g") \ .config("spark.sql.execution.arrow.pyspark.enabled", "true") \ .config("spark.ui.showConsoleProgress", "false") # 创建会话 spark = builder.getOrCreate() # 验证会话 try: # 创建测试DataFrame验证会话是否正常工作 test_df = spark.createDataFrame([(1, "test"), (2, "session")], ["id", "name"]) test_df_count = test_df.count() if test_df_count == 2: st.success("Spark会话创建成功并验证通过") else: st.warning(f"Spark会话验证异常,返回记录数: {test_df_count}") except Exception as e: st.error(f"Spark会话验证失败: {str(e)}") spark.stop() raise return spark except Exception as e: st.error(f"创建Spark会话失败: {str(e)}") st.error("请检查Java版本和Spark配置") st.stop() # 数据预处理函数 def preprocess_data(df): """优化后的数据预处理函数""" # 1. 选择关键特征 available_features = [col for col in df.columns if col in [ 'AGE', 'GENDER', 'ONLINE_DAY', 'TERM_CNT', 'IF_YHTS', 'MKT_STAR_GRADE_NAME', 'PROM_AMT_MONTH', 'is_rh_next' # 目标变量 ]] # 确保目标变量存在 if 'is_rh_next' not in available_features: st.error("错误:数据集中缺少目标变量 'is_rh_next'") return df # 只保留需要的列 df = df[available_features].copy() # 2. 处理缺失值 numeric_cols = ['AGE', 'ONLINE_DAY', 'TERM_CNT', 'P极_AMT_MONTH'] for col in numeric_cols: if col in df.columns: median_val = df[col].median() df[col].fillna(median_val, inplace=True) categorical_cols = ['GENDER', 'MKT_STAR_GRADE_NAME', 'IF_YHTS'] for col in categorical_cols: if col in df.columns: mode_val = df[col].mode()[0] if not df[col].mode().empty else '未知' df[col].fillna(mode_val, inplace=True) # 3. 异常值处理 def handle_outliers(series): Q1 = series.quantile(0.25) Q3 = series.quantile(0.75) IQR = Q3 - Q1 lower_bound = Q1 - 1.5 * IQR upper_bound = Q3 + 1.5 * IQR return series.clip(lower_bound, upper_bound) for col in numeric_cols: if col in df.columns: df[col] = handle_outliers(df[col]) return df # 标题区域 st.markdown("""

精准营销系统

基于机器学习的单宽转融预测

""", unsafe_allow_html=True) # 页面布局 col1, col2 = st.columns([1, 1.5]) # 左侧区域 - 图片和简介 with col1: st.markdown("""

📱 智能营销系统

预测单宽带用户转化为融合套餐用户的可能性

""", unsafe_allow_html=True) # 使用在线图片作为占位符 st.image("https://images.unsplash.com/photo-1551836022-d5d88e9218df?ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D&auto=format&fit=crop&w=1200&q=80", caption="精准营销系统示意图", use_column_width=True) st.markdown("""

📈 系统功能

  • 用户转化可能性预测
  • 高精度机器学习模型
  • 可视化数据分析
  • 精准营销策略制定
""", unsafe_allow_html=True) # 右侧区域 - 功能选择 with col2: st.markdown("""

📋 请选择操作类型

您可以选择数据分析或使用模型进行预测

""", unsafe_allow_html=True) # 功能选择 option = st.radio("操作类型", ["📊 数据分析 - 探索数据并训练模型", "🔍 预测分析 - 预测用户转化可能性"], index=0) # 数据分析部分 if "数据分析" in option: st.markdown("""

数据分析与模型训练

上传数据并训练预测模型</极>

""", unsafe_allow_html=True) # 上传训练数据 train_file = st.file_uploader("上传数据集 (CSV格式, GBK编码)", type=["csv"]) if train_file is not None: try: # 读取数据 train_data = pd.read_csv(train_file, encoding='GBK') # 显示数据预览 with st.expander("数据预览", expanded=True): st.dataframe(train_data.head()) col1, col2 = st.columns(2) col1.metric("总样本数", train_data.shape[0]) col2.metric("特征数量", train_data.shape[1] - 1) # 数据预处理 st.subheader("数据预处理") with st.spinner("数据预处理中..."): processed_data = preprocess_data(train_data) st.success("✅ 数据预处理完成") # 可视化数据分布 st.subheader("数据分布分析") # 目标变量分布 st.markdown("**目标变量分布 (is_rh_next)**") fig, ax = plt.subplots(figsize=(8, 5)) sns.countplot(x='is_rh_next', data=processed_data, palette='viridis') plt.title('用户转化分布 (0:未转化, 1:转化)') plt.xlabel('是否转化') plt.ylabel('用户数量') st.pyplot(fig) # 数值特征分布 st.markdown("**数值特征分布**") numeric_cols = ['AGE', 'ONLINE_DAY', 'TERM_CNT', 'PROM_AMT_MONTH'] # 动态计算子图布局 num_features = len(numeric_cols) if num_features > 0: ncols = 2 nrows = (num_features + ncols - 1) // ncols fig, axes = plt.subplots(nrows, ncols, figsize=(14, 4*nrows)) if nrows > 1 or ncols > 1: axes = axes.flatten() else: axes = [axes] for i, col in enumerate(numeric_cols): if col in processed_data.columns and i < len(axes): sns.histplot(processed_data[col], kde=True, ax=axes[i], color='skyblue') axes[i].set_title(f'{col}分布') axes[i].set_xlabel('') for j in range(i+1, len(axes)): axes[j].set_visible(False) plt.tight_layout() st.pyplot(fig) else: st.warning("没有可用的数值特征") # 特征相关性分析 st.markdown("**特征相关性热力图**") corr_cols = numeric_cols + ['is_rh_next'] if len(corr_cols) > 1: corr_data = processed_data[corr_cols].corr() fig, ax = plt.subplots(figsize=(12, 8)) sns.heatmap(corr_data, annot=True, fmt=".2f", cmap='coolwarm', ax=ax) plt.title('特征相关性热力图') st.pyplot(fig) else: st.warning("特征不足,无法生成相关性热力图") # 模型训练 st.subheader("模型训练") # 训练参数设置 col1, col2 = st.columns(2) test_size = col1.slider("测试集比例", 0.1, 0.4, 0.2, 0.05) random_state = col2.number_input("随机种子", 0, 100, 42) # 开始训练按钮 if st.button("开始训练模型", use_container_width=True): # 创建临时目录用于存储模型 with tempfile.TemporaryDirectory() as tmp_dir: # 修复路径问题:使用绝对路径 model_path = os.path.abspath(os.path.join(tmp_dir, "best_model")) progress_bar = st.progress(0) status_text = st.empty() # 步骤1: 创建Spark会话 status_text.text("步骤1/7: 初始化Spark会话...") spark = create_spark_session() progress_bar.progress(15) # 步骤2: 转换为Spark DataFrame status_text.text("步骤2/7: 转换数据为Spark格式...") spark_df = spark.createDataFrame(processed_data) progress_bar.progress(30) # 步骤3: 划分训练集和测试集 status_text.text("步骤3/7: 划分训练集和测试集...") train_df, test_df = spark_df.randomSplit([1.0 - test_size, test_size], seed=random_state) progress_bar.progress(40) # 步骤4: 特征工程 status_text.text("步骤4/7: 特征工程处理...") categorical_cols = ['GENDER', 'MKT_STAR_GRADE_NAME', 'IF_YHTS'] existing_cat_cols = [col for col in categorical_cols if col in processed_data.columns] # 创建特征处理管道 indexers = [StringIndexer(inputCol=col, outputCol=col+"_index") for col in existing_cat_cols] encoders = [OneHotEncoder(inputCol=col+"_index", outputCol=col+"_encoded") for col in existing_cat_cols] numeric_cols = ['AGE', 'ONLINE_DAY', 'TERM_CNT', 'PROM_AMT_MONTH'] feature_cols = numeric_cols + [col+"_encoded" for col in existing_cat_cols] assembler = VectorAssembler(inputCols=feature_cols, outputCol="features") label_indexer = StringIndexer(inputCol="is_rh_next", outputCol="label") progress_bar.progress(50) # 步骤5: 构建模型 status_text.text("步骤5/7: 构建和训练模型...") # 使用优化的模型配置 rf = RandomForestClassifier( featuresCol="features", labelCol="label", numTrees=50, # 增加树的数量提高精度 maxDepth=5, # 适当增加深度 seed=random_state, featureSubsetStrategy="auto", # 自动选择特征子集策略 impurity="gini" # 使用基尼不纯度 ) pipeline = Pipeline(stages=indexers + encoders + [assembler, label_indexer, rf]) model = pipeline.fit(train_df) progress_bar.progress(80) # 步骤6: 评估模型 status_text.text("步骤6/7: 评估模型性能...") predictions = model.transform(test_df) evaluator_auc = BinaryClassificationEvaluator(labelCol="label", rawPredictionCol="rawPrediction") evaluator_acc = MulticlassClassificationEvaluator(labelCol="label", predictionCol="prediction", metricName="accuracy") evaluator_f1 = MulticlassClassificationEvaluator(labelCol="label", predictionCol="prediction", metricName="f1") auc = evaluator_auc.evaluate(predictions) acc = evaluator_acc.evaluate(predictions) f1 = evaluator_f1.evaluate(predictions) results = { "Random Forest": {"AUC": auc, "Accuracy": acc, "F1 Score": f1} } progress_bar.progress(95) # 步骤7: 保存结果 status_text.text("步骤7/7: 保存模型和结果...") # 确保目录存在 os.makedirs(model_path, exist_ok=True) model.write().overwrite().save(model_path) st.session_state.model_results = results st.session_state.best_model = model st.session_state.model_path = model_path st.session_state.spark = spark progress_bar.progress(100) st.success("🎉 模型训练完成!") # 显示模型性能 st.subheader("模型性能评估") results_df = pd.DataFrame(results).T st.dataframe(results_df.style.format("{:.4f}").background_gradient(cmap='Blues')) # 特征重要性 st.subheader("特征重要性") rf_model = model.stages[-1] feature_importances = rf_model.featureImportances.toArray() importance_df = pd.DataFrame({ "Feature": feature_cols, "Importance": feature_importances }).sort_values("Importance", ascending=False).head(10) fig, ax = plt.subplots(figsize=(10, 6)) sns.barplot(x="Importance", y="Feature", data=importance_df, palette="viridis", ax=ax) plt.title('Top 10 重要特征') st.pyplot(fig) except Exception as e: st.error(f"模型训练错误: {str(e)}") st.error("提示:请检查数据格式和特征列名") # 预测分析部分 else: st.markdown("""

用户转化预测

预测单宽带用户转化为融合套餐的可能性

""", unsafe_allow_html=True) # 上传预测数据 predict_file = st.file_uploader("上传预测数据 (CSV格式, GBK编码)", type=["csv"]) if predict_file is not None: try: # 读取数据 predict_data = pd.read_csv(predict_file, encoding='GBK') # 显示数据预览 with st.expander("数据预览", expanded=True): st.dataframe(predict_data.head()) # 检查是否有模型 if "model_path" not in st.session_state: st.warning("⚠️ 未找到训练好的模型,请先训练模型") st.stop() # 开始预测按钮 if st.button("开始预测", use_container_width=True): progress_bar = st.progress(0) status_text = st.empty() # 步骤1: 数据预处理 status_text.text("步骤1/4: 数据预处理中...") processed_data = preprocess_data(predict_data) progress_bar.progress(25) # 步骤2: 创建Spark会话 status_text.text("步骤2/4: 初始化Spark会话...") if "spark" not in st.session_state: spark = create_spark_session() st.session_state.spark = spark else: spark = st.session_state.spark progress_bar.progress(50) # 步骤3: 预测 status_text.text("步骤3/4: 进行预测...") spark_df = spark.createDataFrame(processed_data) best_model = st.session_state.best_model predictions = best_model.transform(spark_df) progress_bar.progress(75) # 步骤4: 处理结果 status_text.text("步骤4/4: 处理预测结果...") predictions_df = predictions.select( "CCUST_ROW_ID", "probability", "prediction" ).toPandas() # 解析概率值 predictions_df['转化概率'] = predictions_df['probability'].apply(lambda x: float(x[1])) predictions_df['预测结果'] = predictions_df['prediction'].apply(lambda x: "可能转化" if x == 1.0 else "可能不转化") # 添加转化可能性等级 predictions_df['转化可能性'] = pd.cut( predictions_df['转化概率'], bins=[0, 0.3, 0.7, 1], labels=["低可能性", "中可能性", "高可能性"] ) # 保存结果 st.session_state.prediction_results = predictions_df progress_bar.progress(100) st.success("✅ 预测完成!") except Exception as e: st.error(f"预测错误: {str(e)}") # 显示预测结果 if "prediction_results" in st.session_state: st.markdown("""

预测结果

用户转化可能性评估报告

""", unsafe_allow_html=True) result_df = st.session_state.prediction_results # 转化可能性分布 st.subheader("转化可能性分布概览") col1, col2, col3 = st.columns(3) high_conv = (result_df["转化可能性"] == "高可能性").sum() med_conv = (result_df["转化可能性"] == "中可能性").sum() low_conv = (result_df["转化可能性"] == "低可能性").sum() col1.markdown(f"""
{high_conv}
高可能性用户
""", unsafe_allow_html=True) col2.markdown(f"""
{med_conv}
中可能性用户
""", unsafe_allow_html=True) col3.markdown(f"""
{low_conv}
低可能性用户
""", unsafe_allow_html=True) # 转化可能性分布图 fig, ax = plt.subplots(figsize=(8, 5)) conv_counts = result_df["转化可能性"].value_counts() conv_counts.plot(kind='bar', color=['#4CAF50', '#FFC107', '#F44336'], ax=ax) plt.title('用户转化可能性分布') plt.xlabel('可能性等级') plt.ylabel('用户数量') st.pyplot(fig) # 详细预测结果 st.subheader("详细预测结果") # 样式函数 def color_convert(val): if val == "高可能性": return "background-color: #c8e6c9; color: #388e3c;" elif val == "中可能性": return "background-color: #fff9c4; color: #f57f17;" else: return "background-color: #ffcdd2; color: #c62828;" # 格式化显示 display_df = result_df[["CCUST_ROW_ID", "转化概率", "预测结果", "转化可能性"]] styled_df = display_df.style.format({ "转化概率": "{:.2%}" }).applymap(color_convert, subset=["转化可能性"]) st.dataframe(styled_df, height=400) # 下载结果 csv = display_df.to_csv(index=False).encode("utf-8") st.download_button( label="下载预测结果", data=csv, file_name="用户转化预测结果.csv", mime="text/csv", use_container_width=True ) # 页脚 st.markdown("---") st.markdown("""
© 2023 精准营销系统 | 基于Spark和Streamlit开发 | 优化版Spark连接
""", unsafe_allow_html=True) 执行上述代码提示找不到指定路径,pyspark路径 Requirement already satisfied: pyspark in d:\anaconda\lib\site-packages (4.0.0) Requirement already satisfied: py4j==0.10.9.9 in d:\anaconda\lib\site-packages (from pyspark) (0.10.9.9) Note: you may need to restart the kernel to use updated packages. 根据上述提供,修改后完整代码 Requirement already satisfied: pyspark in d:\anaconda\lib\site-packages (4.0.0) Requirement already satisfied: py4j==0.10.9.9 in d:\anaconda\lib\site-packages (from pyspark) (0.10.9.9) Note: you may need to restart the kernel to use updated packages.

filetype

PS C:\Users\Administrator> @{ >> ModuleVersion = '1.0.0' >> RootModule = 'CurlTools.psm1' >> Author = 'Admin' >> CompanyName = 'InternalTools' >> Description = 'Secure curl operations module' >> PowerShellVersion = '5.1' >> FunctionsToExport = @( >> 'Get-CurlPath', >> 'Get-CurlVersion', >> 'Invoke-SecureDownload' >> ) >> } >> Name Value ---- ----- Author Admin Description Secure curl operations module FunctionsToExport {Get-CurlPath, Get-CurlVersion, Invoke-SecureDownload} RootModule CurlTools.psm1 ModuleVersion 1.0.0 CompanyName InternalTools PowerShellVersion 5.1 PS C:\Users\Administrator> function Get-CurlPath { >> # 从配置获取curl路径 >> $config = Get-Content "E:\CurlTools\Config\config.json" | ConvertFrom-Json >> $curlPath = Join-Path $config.CurlPath "curl.exe" >> >> if (-not (Test-Path $curlPath)) { >> throw "curl.exe not found! Check path: $curlPath" >> } >> >> return $curlPath >> } >> >> function Get-CurlVersion { >> # 获取curl版本信息 >> $curlPath = Get-CurlPath >> $version = & $curlPath --version | Select-Object -First 1 >> return $version >> } >> >> function Invoke-SecureDownload { >> param( >> [Parameter(Mandatory=$true)] >> [string]$Url, >> >> [Parameter(Mandatory=$true)] >> [string]$OutputPath >> ) >> >> # 检查域名是否允许 >> $domain = ([System.Uri]$Url).Host >> $config = Get-Content "E:\CurlTools\Config\config.json" | ConvertFrom-Json >> >> if ($domain -notin $config.AllowedDomains) { >> throw "Domain not allowed: $domain! Allowed: $($config.AllowedDomains -join ', ')" >> } >> >> # 确保输出目录存在 >> $outputDir = Split-Path $OutputPath -Parent >> if (-not (Test-Path $outputDir)) { >> New-Item -Path $outputDir -ItemType Directory -Force | Out-Null >> } >> >> # 执行下载 >> $curlPath = Get-CurlPath >> & $curlPath -L -o $OutputPath $Url >> >> if ($LASTEXITCODE -ne 0) { >> throw "Download failed! Error code: $LASTEXITCODE" >> } >> >> Write-Host "Download successful: $OutputPath" -ForegroundColor Green >> } >> >> # 导出所有函数 >> Export-ModuleMember -Function Get-CurlPath, Get-CurlVersion, Invoke-SecureDownload >> Export-ModuleMember : 只能从模块内调用 Export-ModuleMember cmdlet。 所在位置 行:55 字符: 1 + Export-ModuleMember -Function Get-CurlPath, Get-CurlVersion, Invoke-S ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : PermissionDenied: (:) [Export-ModuleMember], InvalidOperationException + FullyQualifiedErrorId : Modules_CanOnlyExecuteExportModuleMemberInsideAModule,Microsoft.PowerShell.Commands.Expo rtModuleMemberCommand PS C:\Users\Administrator> # Set UTF-8 encoding >> [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 >> $OutputEncoding = [System.Text.Encoding]::UTF8 >> chcp 65001 | Out-Null >> >> # Add module path >> $modulePath = "E:\CurlTools\Modules" >> if ($env:PSModulePath -notlike "*$modulePath*") { >> $env:PSModulePath += ";$modulePath" >> } >> >> # Auto-load module >> Import-Module CurlTools -Force -ErrorAction SilentlyContinue >> PS C:\Users\Administrator> # 下载允许域名的文件 >> Invoke-SecureDownload -Url "https://example.com" -OutputPath "E:\Downloads\example.html" >> >> # 尝试下载禁止域名(会报错) >> Invoke-SecureDownload -Url "https://forbidden.com" -OutputPath "E:\Downloads\forbidden.html" >> Download failed! Error code: 23 所在位置 E:\CurlTools\Modules\CurlTools\CurlTools.psm1:29 字符: 9 + throw "Download failed! Error code: $LASTEXITCODE" + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : OperationStopped: (Download failed! Error code: 23:String) [], RuntimeException + FullyQualifiedErrorId : Download failed! Error code: 23 PS C:\Users\Administrator> # 获取curl路径 >> $curlPath = Get-CurlPath >> Write-Host "Curl executable: $curlPath" >> >> # 获取curl版本 >> $version = Get-CurlVersion >> Write-Host "Curl version: $version" >> Curl executable: E:\CurlTools\CurlBin\curl.exe Curl version: curl 8.15.0 (x86_64-w64-mingw32) libcurl/8.15.0 LibreSSL/4.1.0 zlib/1.3.1.zlib-ng brotli/1.1.0 zstd/1.5.7 WinIDN libpsl/0.21.5 libssh2/1.11.1 nghttp2/1.66.0 ngtcp2/1.14.0 nghttp3/1.11.0 PS C:\Users\Administrator> PowerShell会话 >> ├── $PROFILE (自动加载) >> │ └── 导入CurlTools模块 >> ├── CurlTools模块 >> │ ├── Get-CurlPath >> │ ├── Get-CurlVersion >> │ └── Invoke-SecureDownload >> └── 配置文件 >> ├── config.json (配置设置) >> └── 日志文件 >> PowerShell会话 : 无法将“PowerShell会话”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:1 字符: 1 + PowerShell会话 + ~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (PowerShell会话:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 自动加载 : 无法将“自动加载”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:2 字符: 15 + ├── $PROFILE (自动加载) + ~~~~ + CategoryInfo : ObjectNotFound: (自动加载:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException │ : 无法将“│”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:3 字符: 1 + │ └── 导入CurlTools模块 + ~ + CategoryInfo : ObjectNotFound: (│:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException ├── : 无法将“├──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:4 字符: 1 + ├── CurlTools模块 + ~~~ + CategoryInfo : ObjectNotFound: (├──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException │ : 无法将“│”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:5 字符: 1 + │ ├── Get-CurlPath + ~ + CategoryInfo : ObjectNotFound: (│:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException │ : 无法将“│”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:6 字符: 1 + │ ├── Get-CurlVersion + ~ + CategoryInfo : ObjectNotFound: (│:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException │ : 无法将“│”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:7 字符: 1 + │ └── Invoke-SecureDownload + ~ + CategoryInfo : ObjectNotFound: (│:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException └── : 无法将“└──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:8 字符: 1 + └── 配置文件 + ~~~ + CategoryInfo : ObjectNotFound: (└──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException 配置设置 : 无法将“配置设置”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:9 字符: 22 + ├── config.json (配置设置) + ~~~~ + CategoryInfo : ObjectNotFound: (配置设置:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException └── : 无法将“└──”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。 所在位置 行:10 字符: 5 + └── 日志文件 + ~~~ + CategoryInfo : ObjectNotFound: (└──:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException PS C:\Users\Administrator>

量子学园
  • 粉丝: 32
上传资源 快速赚钱