

纯小白怎么装 Python 环境
写在开头 无论什么目的,我都建议你使用 uv 来安装 python。有很多人也会选择 conda,但我认为 uv 相对更好一些。如果有人给你发了一个 yaml,叫你复制这个环境,那一般是用 conda。。但是对于新项目,我建议你使用 uv,不过它有一定学习成本,需要记忆命令 uv 安装 python教程 对于 mac,安装 homebrew /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" 然后一路回车确认就行 等待 brew 安装好,我们运行brew install uv 等待 uv 安装好,我们进入我们的项目的路径的,然后运行 uv init --name my-app . -p3.12,3.12 替换为你自己需要的 python 版本,my-app 替换为你想要的项目名称 然后,你就成功得到了一个环境。以下是一些常用命令及与普通 python 命令映射 传统 Python 命令 uv 对应命令 说明 python script.py uv run script.py 在 uv 管理的环境中运行脚本,自动处理虚拟环境和依赖。 pip install package uv add package 在项目中添加依赖。uv 会更新 pyproject.toml 和锁定文件。 pip uninstall package uv remove package 从项目中移除依赖。 python -m venv .venv / source .venv/bin/activate (隐式)uv 管理 .venv 或环境 uv 在初始化或第一次 uv add 时会自动建立环境,不必手动激活。 virtualenv venv / venv venv uv venv uv 提供创建虚拟环境的命令(传统 workflow 的一部分) pip freeze > requirements.txt / pip install -r requirements.txt uv lock(生成锁文件) + uv sync(安装) uv 用锁文件(uv.lock)替代 requirements.txt,确保可重复环境。 python setup.py sdist bdist_wheel / twine upload dist/* uv build + uv publish 项目打包与发布流程由 uv 提供。 pipx / python -m uvx 或 uv tool run 用于一次性运行或安装 CLI 工具包,uv 提供 “tool” 子命令流程。 pyenv install 3.x / pyenv local 3.x uv python install 3.x +项目配置 uv 支持管理 Python 版本,自动下载并切换。 pip install -e . / python setup.py develop uv tool install . -e 或 uv add –editable . 开发安装项目(使其在系统可用/可运行)使用 uv 的 “tool install” 或项目安装流程。 conda 安装教程 安装 mambaforge(就是 conda)brew install mambaforge,根据指引回车 运行conda init zsh或者conda init bash(根据你的终端类型) 创建一个环境 conda create -n py311 python=3.11,py311 替换名称,3.11 替换 python 版本 激活这个环境conda activate py311,然后你就可以正确地运行常规的 python 命令(比如 pip 等)
React 遇到的一些知识(Adding...)
字段 ellipsis 意思是 columns 中的当单元格中内容太长,显示… const columns: ColumnsType<FileInfo> = [ { title: '文件名', dataIndex: 'file_name', key: 'file_name', ellipsis: true, render: (text: string) => <Text strong>{text}</Text>, }, { title: '文件大小', dataIndex: 'file_size', key: 'file_size', width: 120, render: (size: number) => formatFileSize(size), }, { title: '上传时间', dataIndex: 'uploaded_at', key: 'uploaded_at', width: 180, render: (date: string) => formatDateTime(date), }, { title: '操作', key: 'actions', width: 220, render: (_, record: FileInfo) => ( <Space size="small"> <Button type="link" icon={<EyeOutlined />} onClick={() => handlePreview(record)} > 预览 </Button> <Button type="link" icon={<DownloadOutlined />} onClick={() => handleDownload(record)} > 下载 </Button> <Button type="link" danger icon={<DeleteOutlined />} onClick={() => handleDelete(record)} > 删除 </Button> </Space> ), }, ];
XXX 已损坏,你应该拖到废纸篓中
这是由于 MacOS 不允许不信任的应用 打开终端,输入(先别运行 sudo xattr -d com.apple.quarantine 然后打开你的 FInder -> 应用程序,将有问题的 APP 拖进终端,然后大概是这种效果 sudo xattr -d com.apple.quarantine /Applications/PicGo.app 这时候再运行,就能打开了。真打不开的就是你版本没下载对或者程序真的有问题
React报错 The requested module does not provide an export named 'Subtask'
format.ts:1 Uncaught SyntaxError: The requested module ‘/src/types/index.ts’ does not provide an export named ‘Subtask’ (at format.ts:1:10) 添加 type 即可
搭建一个 Vite + React 项目
前期准备 首先你需要安装 node.js,mac 使用如下命令,windows linux 请自查 brew install node 然后全局安装 pnpm(我从来不用 npm,pnpm 是最好的) npm install pnpm -g pnpm -v 然后在项目路径中使用 vite 初始化项目 pnpm create vite . -- --template react-ts 以下是我的一些选择 $ pnpm create vite . -- --template react-ts .../199e71df160-9ee0 | +1 + .../199e71df160-9ee0 | Progress: resolved 1, reused 0, downloaded 1, added 1, done │ ◇ Current directory is not empty. Please choose how to proceed: │ Ignore files and continue │ ◇ Package name: │ iselect-ui │ ◇ Select a framework: │ React │ ◇ Select a variant: │ TypeScript + React Compiler │ ◇ Use rolldown-vite (Experimental)?: │ No │ ◇ Install with pnpm and start now? │ Yes │ ◇ Scaffolding project in /Users/dorian/Documents/Programme/iSelect/iSelect-UI... │ ◇ Installing dependencies with pnpm... VITE v7.1.10 ready in 603 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help 然后进入浏览器打开网址就可以看到啦
在一个 Git 仓库中聚合两个项目
主要操作 现在我们有两个仓库,servicecomp 和 srvc-frontend,我想把他们在一个仓库中聚合一下(比如前后端项目),使用 subtree # 0) 若父仓库已误把两个子仓库当普通目录 add 了,先从索引移除(不删本地文件) git rm --cached -r servicecomp srvc-frontend || true # 1) 临时挪开本地已有目录(subtree 会自己创建对应目录) mv servicecomp servicecomp.tmp mv srvc-frontend srvc-frontend.tmp 两个子项目的远端 URL 加进来,起两个新名字 # 2) 后端 servicecomp git remote add servicecomp-origin [email protected]:Ch1ldKing/HITCS-CloudNative-SpringCloud.git git fetch servicecomp-origin git subtree add --prefix=servicecomp servicecomp-origin main -m "Add servicecomp via subtree" # 暂存更改 git stash push -u -m "wip before adding srvc-frontend" # 3) 前端 srvc-frontend(URL 和分支名请替换) git remote add srvc-frontend-origin <你的前端仓库URL> git fetch srvc-frontend-origin git subtree add --prefix=srvc-frontend srvc-frontend-origin <分支名> -m "Add srvc-frontend via subtree" # 改动取回来 git stash pop 错误 错误 1 $ git subtree add --prefix=servicecomp servicecomp-origin main -m "Add servicecomp via subtree" fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' fatal: working tree has modifications. Cannot add. fatal: ambiguous argument ‘HEAD’ ...
Ubuntu 安装 K8s 所有的坑
在ubuntu 安装时,手动配置 ipv4,name servers 和 searchdomains 是什么 Name Servers(DNS 服务器) 用于解析域名。例如: • 8.8.8.8, 8.8.4.4(Google DNS) • 或者你网络提供商的 DNS,如 114.114.114.114 填写多个时用 逗号分隔。 Search Domains(搜索域) 这个选项是为了方便局域网域名解析。举个例子: • 如果你填写了 example.com,当你在终端中访问 server1,系统会自动尝试解析为 server1.example.com。 • 多个域名可以用空格分隔:example.com local.lan 这主要用于企业或学校内的内网环境,不填也可以。 我使用虚拟机和 NAT 网络,如何配置代理?我的宿主机上使用 Clash 确认 Clash 开放了公网访问(监听 0.0.0.0) 编辑 Clash 的配置文件 ~/.config/clash/config.yaml 或 clash.meta.yaml,确保监听地址改为: mixed-port: 7890 allow-lan: true # ✅ 允许局域网设备访问 Clash bind-address: 0.0.0.0 # ✅ 不要写 127.0.0.1 在虚拟机中设置代理 在 Ubuntu 虚拟机里,可以这样设置环境变量方式配置代理: export http_proxy="http://192.168.79.1:7890" export https_proxy="http://192.168.79.1:7890" export all_proxy="socks5://192.168.79.1:7891" K8s 安装软件仓库地址 关于 https://github.com/kubernetes/kubernetes/issues/123673 , Kubernetes 更改了其软件包仓库(repository)的地址。旧的仓库地址(通常是 apt.kubernetes.io)已弃用,并迁移到了新的地址 pkgs.k8s.io ...
Flutter 学习笔记
本笔记基于该教程, 让我们说谢谢 Google 写着感觉和 ArkTS 和 Kotlin 很像 PS:如果你使用 Windows,请将所有 ⌘ (Mac 上的 Command 键)视为 Ctrl 键 Flutter环境配置 按照 flutter brew install flutter 安装 VSCode(其他的也行)插件 安装 xcode xcode-select --install 创建一个新项目 F1 -> flutter new -> Application->填项目名称,选路径 替换以下内容 pubspec.yaml name: 你的项目名称 description: A new Flutter project. publish_to: 'none' # Remove this line if you wish to publish to pub.dev version: 0.0.1+1 environment: sdk: '>=2.19.4 <4.0.0' dependencies: flutter: sdk: flutter english_words: ^4.0.0 provider: ^6.0.0 dev_dependencies: flutter_test: sdk: flutter flutter_lints: ^2.0.0 flutter: uses-material-design: true 替换 analysis_options.yaml (用于代码分析器) include: package:flutter_lints/flutter.yaml linter: rules: prefer_const_constructors: false prefer_final_fields: false use_key_in_widget_constructors: false prefer_const_literals_to_create_immutables: false prefer_const_constructors_in_immutables: false avoid_print: false 替换lib/main.dart,经典的面向对象语言 import 'package:english_words/english_words.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return ChangeNotifierProvider( create: (context) => MyAppState(), child: MaterialApp( title: 'Namer App', theme: ThemeData( useMaterial3: true, colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepOrange), ), home: MyHomePage(), ), ); } } class MyAppState extends ChangeNotifier { var current = WordPair.random(); } class MyHomePage extends StatelessWidget { @override Widget build(BuildContext context) { var appState = context.watch<MyAppState>(); return Scaffold( body: Column( children: [ Text('A random idea:'), Text(appState.current.asLowerCase), ], ), ); } } 运行这个新项目 停留在 main.dart 上,选择当前的目标运行平台(右下角) 我这里选了 Mac,然后点击运行标志,结果报错了在 stackoverflow 找到xcrun: error: unable to find utility "xcodebuild", not a developer tool or in PATH。如果装了 Xcode APP 版本,进入 Settings->Locations,改一下 command line tools 的路径 再运行,还是报错 运行 flutter doctor -v,发现没装 cocoapods。运行brew install cocoapods即可 再运行,还是一样的报错。在这里找到原因,有人就是因为被 iCloud 文件提供器加了 com.apple.fileprovider.fpfs#P 才一直失败,- 任何打包进 .app 的文件只要带有资源分叉或 Finder 信息,CodeSign 都会拒绝。所以我把项目移出了 iCloud 同步的文件夹,然后清理资源重新运行 # 1) Flutter 清理 + 移除构建输出 flutter clean rm -rf build/macos # 2) 删除 Xcode 派生数据 rm -rf ~/Library/Developer/Xcode/DerivedData/* # 3) 递归清理整个项目树的扩展属性(包含将来要进 .app 的一切) xattr -rc . # 4) 若你从网上下过三方二进制/压缩包,顺便去掉隔离标记 xattr -dr com.apple.quarantine . # 5) 重新预拉取 macOS 引擎构件(避免 SDK 自身产物带脏属性) flutter precache --macos # 6) 重新构建 flutter run -d macos 这次成功了,弹出了我们的 APP 再试试 iOS 平台,右下角构建平台选择 ios simulator再打开 lib/main.dart ,点击右上角运行标志,等待一会也可以正确显示 热重载 我们修改文字,并按 ⌘+S,可看到程序中的文字发生了变化(注意 Web 平台不支持) 添加一个按钮 我们继续修改,修改以下内容 ...
SVG 颜色问题
我们使用 Tailwind 的情况下,想通过 class 直接给我们的 SVG 图标设置颜色,或者跟随父组件,需要用到这个 fill=“currentColor”,然后就可以在 <template> <svg t="1749727002733" class="icon" viewBox="0 0 1394 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5650" width="200" height="200"> <path d="M808.665066 968.123525a139.174837 139.174837 0 0 1-222.989114 0L28.061551 224.448838A140.525626 140.525626 0 0 1 0 140.133462C0 62.746326 62.484883 0 139.567002 0h1115.228801c30.283817 0 59.739731 9.891261 83.944998 28.192273 61.569833 46.558646 73.901229 134.425289 27.538666 196.256565L808.665066 968.123525z" fill="currentColor" p-id="5651"></path> </svg> </template> 然后在 vue 中使用,可以跟随父组件 <div :class="[ 'flex items-center px-2 py-1 rounded-full text-xs font-medium min-w-[70px] justify-center', category.change > 0 ? 'bg-red-100 text-red-800' : 'bg-green-100 text-green-800']"> <IconArrowDown :class="['w-3 h-3 mr-1', category.change > 0 ? 'rotate-180' : '']" /> {{ Math.abs(category.change).toFixed(2) }}% </div> 还可以直接指定颜色 ...
哈工大云原生实验总结
Github 链接 作业要求: VmWare 在三台 Ubuntu 虚拟机动手实现 K8S 集群 实现 SpringCloud,服务注册,服务发现,服务负载均衡 实现服务远程调用 OpenFeign 实现 DevOps 自动 CI/CD(Jenkins 或 Github Actions) 实现 至少 7 个微服务 实现前端 实现 Agent 工作流并能体现在前端界面 实现 K8S 集群监控 metrics 我们做的: 使用 Ubuntu 22.04 搭建 K8S 集群 使用 Kubernetes Dashboard 与 Grafana 进行集群监控 使用 NFS 动态分配微服务容器空间 使用 Ingress-nginx 实现域名访问集群服务(对 nacos,grafana,sentinel 等进行 DNS 解析与负载均衡) 使用 Nacos 实现服务注册(实验指导书使用 Eureka) 使用 OpenFeign 实现服务远程调用 使用 SpringGateway 进行服务路由与负载均衡 使用 Sentinel 进行服务限流,流量监控 使用 Nacos 实现服务配置中心 使用 Dify 搭建 Agen t工作流 使用 Jenkins 自动 CICD 使用 SpringAI 搭建 MCP 服务器供 Agent 使用