pip设置代理的几种方法

通常情况下,国内使用PIP可以参考Pypi国内镜像设置来设置国内镜像以加快安装速度。 但有的pip软件包国内镜像出于各种考虑并未收录,因此就得使用Pipy.org的官方源安装,在网络状况不理想的情况下,我们可以使用设置代理来加速安装过程。 例如,我们已经获得了代理服务的配置,如下: http://127.0.0.1:2080 socks://127.0.0.1:2080 如果是linux系统,可以使用系统自有的环境变量http_proxy、https_proxy $ export HTTP_PROXY=http://127.0.0.1:2080 $ export HTTPS_PROXY=http://127.0.0.1:2080 使用pip自带选项--proxy来使用代理 $ pip install --proxy=http://127.0.0.1:2080 jupyter 使用pip配置文件pip.conf或pip.ini来设置代理 Windows下是pip.ini,linux下是~/.pip/pip.conf或/etc/pip.conf [global] proxy = http://127.0.0.1:2080

十二月 12, 2024 · JQX

tar使用详解

tar是一款经典的打包程序,用于将多个文件进行打包存储,tar设计之初就是为了方便将文件存储与磁带上,tar这个名字就是由此而来,表示Tape Archiver。 tar可以方便的对多个文件进行打包处理,也可对已经打包好的文件(.tar文件)进行查看增补等操作。 人们通常在打包完成后,还会进行压缩操作,使用tar我们可以方便的将打包压缩两个操作合二为一,一次性输出压缩后的结果。 tar最常用的四个参数 适用tar时,后面的参数可以分别写,也可以写在一起,即tar -cf name和tar -c -f=name效果相同。 创建新的tar包 -c 或者 --create 查看tar包内容 -t 或者 --list 从tar包提取内容 -x 或者 --extract 指定tar文件名 -f archive-name 或者 --file=archive-name 显示操作详情 -v 或者 --verbose tar打包常用操作实例 tar打包文件 $tar -cf t.tar document.docx sheets.xlsx text.txt tar查看内容 $ tar -tf t.tar document.docx sheets.xlsx text.txt tar提取内容 ## 提取t.tar包内容 tar -xf t.tar ## 提取t.tar包中指定的文件text.txt,注意这里必须用参数全名,不能用简写 tar --extract --file=t.tar text.txt tar打包压缩 tar可以在打包时同时条用压缩程序压缩文档,支持多种压缩程序,如:gzip, bzip2, lzip, lzma, lzop, zstd, xz和compress。 ...

十二月 3, 2024 · JQX

Linux一键修改swap脚本

在此分享一个Linux一键修改swap文件脚本,方便大家使用。 下载脚本 wget https://unixetc.com/res/swap.sh chmod +x ./swap.sh 脚本使用示例,注意必须以root权限执行该脚本 ## 运行脚本 ./swap.sh ——————————————————————————————————————— Linux VPS一键添加/删除swap脚本 1、添加swap 2、删除swap ——————————————————————————————————————— 请输入数字 [1-2]:1 请输入需要添加的swap(建议为内存的1.5-2倍) 请输入swap数值(单位M):2000 swap已存在,swap设置失败,请先运行脚本删除swap后重新设置! ##提示已存在swap,应该选择2删除了再次添加 ——————————————————————————————————————— Linux VPS一键添加/删除swap脚本 1、添加swap 2、删除swap ——————————————————————————————————————— 请输入数字 [1-2]:2 swap已发现,正在将其移除... swap已删除! ##添加swap ——————————————————————————————————————— Linux VPS一键添加/删除swap脚本 1、添加swap 2、删除swap ——————————————————————————————————————— 请输入数字 [1-2]:1 请输入需要添加的swap(建议为内存的1.5-2倍) 请输入swap数值(单位M):2000 swap未发现,正在为其创建swap swap创建成功,并查看信息: Filename Type Size Used Priority /swap file 2047996 338952 -2 SwapCached: 127192 kB SwapTotal: 2047996 kB SwapFree: 1709044 kB

十一月 28, 2024 · JQX

使用pandoc批量转换rst为md

安装软件 下载安装pandoc Windows版下载安装pandoc-3.5-windows-x86_64.msi (访问密码: 3705) Debian/Ubuntu使用如下命令安装 apt install pandoc 安装Python Windows版下载安装python-3.13.0-amd64.exe (访问密码: 3705) Debian/Ubuntu使用如下命令安装 apt install python3 python3-pip 安装Pypandoc Pypandoc是一款python插件,可以调用Pandoc进行使用。 pip install pypandoc Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting pypandoc Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ff/bd/cf1dd70b95f3366f3c457c5259ed8f032122210441407b6ed281d7fcbb8c/pypandoc-1.14-py3-none -any.whl (21 kB) Installing collected packages: pypandoc Successfully installed pypandoc-1.14 Python代码 新建plzh.py文件,内容如下,或者点击这里下载文件plzhrst2md.py (访问密码: 3705) import os def get_file_name(file_dir): for root, dirs, files in os.walk(file_dir): #获取当前目录 for file in files: if os.path.splitext(file)[1] == ".rst": #搜索rst文件 os.chdir(root) print("Conversion ..." + "pandoc " + file + " -o " + os.path.splitext(file)[0] + ".md") os.system("pandoc " + file + " -o " + os.path.splitext(file)[0] + ".md") #调用pandoc开始转换到同目录 print("Done!") if __name__ == "__main__": get_file_name(r"D:\dls\doc") #自定义文件夹 将文件复制到.rst文件目录,点击运行即可,转换后的.md文件和.rst文件同目录同文件名。

十一月 20, 2024 · JQX

VPS安装Bluesky PDS

Bluesky是一个去中心化的分散式社交系统,与 Mastodon (长毛象) 相似,不过Bluesky 自行开发的AT Protocol协议无法与 Mastodon 的 ActivityPub 互通。 同样是可自行架设的社交平台,比较特别的是 Bluesky 并不像 Mastodon 一样包含了前端网页(web),它只有提供API功能,需要专门的前端来进行登录管理。 自行部署的Bluesky服务器被称为个人数据服务器 (Personal Data Server, PDS),使用者可以在 bsky.app 网页版或 iOS、Android客户端中登录自行部署的pds服务。 pds推荐主机配置 操作系统 Ubuntu 22.04 内存 (RAM) 1 GB CPU核心 1 CPU构架 amd64, arm64 硬盘 20 GB SSD 可服务账号数 20 VPS部署PDS实例 域名设置 以pds.p9.pub为例,服务器IP为195.192.118.6 将pds.p9.pub和*.pds.p9.pub的A记录修改为195.192.118.6 安装pds 通过以下命令下载安装脚本 wget https://raw.githubusercontent.com/bluesky-social/pds/main/installer.sh 然后运行bash ./installer.sh来开始安装 bash ./installer.sh * Detected supported distribution Debian 12 --------------------------------------- Add DNS Record for Public IP --------------------------------------- From your DNS provider's control panel, create the required DNS record with the value of your server's public IP address. + Any DNS name that can be resolved on the public internet will work. + Replace example.com below with any valid domain name you control. + A TTL of 600 seconds (10 minutes) is recommended. Example DNS record: NAME TYPE VALUE ---- ---- ----- example.com A 195.192.118.6 *.example.com A 195.192.118.6 **IMPORTANT** It's recommended to wait 3-5 minutes after creating a new DNS record before attempting to use it. This will allow time for the DNS record to be fully updated. ## 输入域名和管理员邮箱 Enter your public DNS address (e.g. example.com): pds.p9.pub Enter an admin email address (e.g. [email protected]): [email protected] Hit:1 http://security.debian.org/debian-security bookworm-security InRelease Hit:2 http://deb.debian.org/debian bookworm InRelease Hit:3 http://deb.debian.org/debian bookworm-updates InRelease Hit:4 https://download.docker.com/linux/debian bookworm InRelease Reading package lists... Done Reading package lists... Done Building dependency tree... Done Reading state information... Done ca-certificates is already the newest version (20230311). curl is already the newest version (7.88.1-10+deb12u7). lsb-release is already the newest version (12.0-1). lsb-release set to manually installed. openssl is already the newest version (3.0.14-1~deb12u2). openssl set to manually installed. The following additional packages will be installed: dirmngr gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm libassuan0 libjq1 libksba8 libnpth0 libonig5 pinentry-curses Suggested packages: pinentry-gnome3 tor parcimonie xloadimage scdaemon pinentry-doc sqlite3-doc The following NEW packages will be installed: dirmngr gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client gpg-wks-server gpgconf gpgsm jq libassuan0 libjq1 libksba8 libnpth0 libonig5 pinentry-curses sqlite3 xxd 0 upgraded, 19 newly installed, 0 to remove and 0 not upgraded. Need to get 8,706 kB of archives. After this operation, 17.8 MB of additional disk space will be used. Get:1 http://deb.debian.org/debian bookworm/main amd64 libassuan0 amd64 2.5.5-5 [48.5 kB] Get:2 http://deb.debian.org/debian bookworm/main amd64 gpgconf amd64 2.2.40-1.1 [564 kB] Get:3 http://deb.debian.org/debian bookworm/main amd64 libksba8 amd64 1.6.3-2 [128 kB] Get:4 http://deb.debian.org/debian bookworm/main amd64 libnpth0 amd64 1.6-3 [19.0 kB] Get:5 http://deb.debian.org/debian bookworm/main amd64 dirmngr amd64 2.2.40-1.1 [792 kB] Get:6 http://deb.debian.org/debian bookworm/main amd64 gnupg-l10n all 2.2.40-1.1 [1,093 kB] Get:7 http://deb.debian.org/debian bookworm/main amd64 gnupg-utils amd64 2.2.40-1.1 [927 kB] Get:8 http://deb.debian.org/debian bookworm/main amd64 gpg amd64 2.2.40-1.1 [949 kB] Get:9 http://deb.debian.org/debian bookworm/main amd64 pinentry-curses amd64 1.2.1-1 [77.4 kB] Get:10 http://deb.debian.org/debian bookworm/main amd64 gpg-agent amd64 2.2.40-1.1 [695 kB] Get:11 http://deb.debian.org/debian bookworm/main amd64 gpg-wks-client amd64 2.2.40-1.1 [541 kB] Get:12 http://deb.debian.org/debian bookworm/main amd64 gpg-wks-server amd64 2.2.40-1.1 [531 kB] Get:13 http://deb.debian.org/debian bookworm/main amd64 gpgsm amd64 2.2.40-1.1 [671 kB] Get:14 http://deb.debian.org/debian bookworm/main amd64 gnupg all 2.2.40-1.1 [846 kB] Get:15 http://deb.debian.org/debian bookworm/main amd64 libonig5 amd64 6.9.8-1 [188 kB] Get:16 http://deb.debian.org/debian bookworm/main amd64 libjq1 amd64 1.6-2.1 [135 kB] Get:17 http://deb.debian.org/debian bookworm/main amd64 jq amd64 1.6-2.1 [64.9 kB] Get:18 http://deb.debian.org/debian bookworm/main amd64 sqlite3 amd64 3.40.1-2 [353 kB] Get:19 http://deb.debian.org/debian bookworm/main amd64 xxd amd64 2:9.0.1378-2 [83.7 kB] Fetched 8,706 kB in 0s (36.3 MB/s) Selecting previously unselected package libassuan0:amd64. (Reading database ... 36657 files and directories currently installed.) Preparing to unpack .../00-libassuan0_2.5.5-5_amd64.deb ... Unpacking libassuan0:amd64 (2.5.5-5) ... Selecting previously unselected package gpgconf. Preparing to unpack .../01-gpgconf_2.2.40-1.1_amd64.deb ... Unpacking gpgconf (2.2.40-1.1) ... Selecting previously unselected package libksba8:amd64. Preparing to unpack .../02-libksba8_1.6.3-2_amd64.deb ... Unpacking libksba8:amd64 (1.6.3-2) ... Selecting previously unselected package libnpth0:amd64. Preparing to unpack .../03-libnpth0_1.6-3_amd64.deb ... Unpacking libnpth0:amd64 (1.6-3) ... Selecting previously unselected package dirmngr. Preparing to unpack .../04-dirmngr_2.2.40-1.1_amd64.deb ... Unpacking dirmngr (2.2.40-1.1) ... Selecting previously unselected package gnupg-l10n. Preparing to unpack .../05-gnupg-l10n_2.2.40-1.1_all.deb ... Unpacking gnupg-l10n (2.2.40-1.1) ... Selecting previously unselected package gnupg-utils. Preparing to unpack .../06-gnupg-utils_2.2.40-1.1_amd64.deb ... Unpacking gnupg-utils (2.2.40-1.1) ... Selecting previously unselected package gpg. Preparing to unpack .../07-gpg_2.2.40-1.1_amd64.deb ... Unpacking gpg (2.2.40-1.1) ... Selecting previously unselected package pinentry-curses. Preparing to unpack .../08-pinentry-curses_1.2.1-1_amd64.deb ... Unpacking pinentry-curses (1.2.1-1) ... Selecting previously unselected package gpg-agent. Preparing to unpack .../09-gpg-agent_2.2.40-1.1_amd64.deb ... Unpacking gpg-agent (2.2.40-1.1) ... Selecting previously unselected package gpg-wks-client. Preparing to unpack .../10-gpg-wks-client_2.2.40-1.1_amd64.deb ... Unpacking gpg-wks-client (2.2.40-1.1) ... Selecting previously unselected package gpg-wks-server. Preparing to unpack .../11-gpg-wks-server_2.2.40-1.1_amd64.deb ... Unpacking gpg-wks-server (2.2.40-1.1) ... Selecting previously unselected package gpgsm. Preparing to unpack .../12-gpgsm_2.2.40-1.1_amd64.deb ... Unpacking gpgsm (2.2.40-1.1) ... Selecting previously unselected package gnupg. Preparing to unpack .../13-gnupg_2.2.40-1.1_all.deb ... Unpacking gnupg (2.2.40-1.1) ... Selecting previously unselected package libonig5:amd64. Preparing to unpack .../14-libonig5_6.9.8-1_amd64.deb ... Unpacking libonig5:amd64 (6.9.8-1) ... Selecting previously unselected package libjq1:amd64. Preparing to unpack .../15-libjq1_1.6-2.1_amd64.deb ... Unpacking libjq1:amd64 (1.6-2.1) ... Selecting previously unselected package jq. Preparing to unpack .../16-jq_1.6-2.1_amd64.deb ... Unpacking jq (1.6-2.1) ... Selecting previously unselected package sqlite3. Preparing to unpack .../17-sqlite3_3.40.1-2_amd64.deb ... Unpacking sqlite3 (3.40.1-2) ... Selecting previously unselected package xxd. Preparing to unpack .../18-xxd_2%3a9.0.1378-2_amd64.deb ... Unpacking xxd (2:9.0.1378-2) ... Setting up libksba8:amd64 (1.6.3-2) ... Setting up libnpth0:amd64 (1.6-3) ... Setting up libassuan0:amd64 (2.5.5-5) ... Setting up xxd (2:9.0.1378-2) ... Setting up gnupg-l10n (2.2.40-1.1) ... Setting up gpgconf (2.2.40-1.1) ... Setting up libonig5:amd64 (6.9.8-1) ... Setting up sqlite3 (3.40.1-2) ... Setting up gpg (2.2.40-1.1) ... Setting up gnupg-utils (2.2.40-1.1) ... Setting up pinentry-curses (1.2.1-1) ... Setting up gpg-agent (2.2.40-1.1) ... Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-browser.socket → /usr/lib/systemd/user/gpg-agent-browser.socket. Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-extra.socket → /usr/lib/systemd/user/gpg-agent-extra.socket. Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent-ssh.socket → /usr/lib/systemd/user/gpg-agent-ssh.socket. Created symlink /etc/systemd/user/sockets.target.wants/gpg-agent.socket → /usr/lib/systemd/user/gpg-agent.socket. Setting up libjq1:amd64 (1.6-2.1) ... Setting up gpgsm (2.2.40-1.1) ... Setting up dirmngr (2.2.40-1.1) ... Created symlink /etc/systemd/user/sockets.target.wants/dirmngr.socket → /usr/lib/systemd/user/dirmngr.socket. Setting up gpg-wks-server (2.2.40-1.1) ... Setting up jq (1.6-2.1) ... Setting up gpg-wks-client (2.2.40-1.1) ... Setting up gnupg (2.2.40-1.1) ... Processing triggers for man-db (2.11.2-2) ... Processing triggers for libc-bin (2.36-9+deb12u8) ... * Configuring Docker daemon * Creating data directory /pds * Creating Caddy data directory * Creating Caddy config directory * Creating Caddy config file * Downloading PDS compose file * Starting the pds systemd service Created symlink /etc/systemd/system/default.target.wants/pds.service → /etc/systemd/system/pds.service. * Downloading pdsadmin ======================================================================== PDS installation successful! ------------------------------------------------------------------------ Check service status : sudo systemctl status pds Watch service logs : sudo docker logs -f pds Backup service data : /pds PDS Admin command : pdsadmin Required Firewall Ports ------------------------------------------------------------------------ Service Direction Port Protocol Source ------- --------- ---- -------- ---------------------- HTTP TLS verification Inbound 80 TCP Any HTTP Control Panel Inbound 443 TCP Any Required DNS entries ------------------------------------------------------------------------ Name Type Value ------- --------- --------------- pds.p9.pub A 195.192.118.6 *.pds.p9.pub A 195.192.118.6 Detected public IP of this server: 195.192.118.6 To see pdsadmin commands, run "pdsadmin help" ======================================================================== ### 是否添加账号,这里选择y开始设置账号,选择n的话后期可以通过pdsadmin account create来添加账号 Create a PDS user account? (y/N): y ## 设置邮箱 Enter an email address (e.g. [email protected]): [email protected] ## 设置账号名,注意格式jqx.pds.p9.pub Enter a handle (e.g. alice.pds.p9.pub): jqx.pds.p9.pub ## 账号添加完成 Account created successfully! ----------------------------- Handle : jqx.pds.p9.pub DID : did:plc:dgsdfgas34dfpqilzhutwbtvkg Password : qNiugTBUQ*******x7Bdwt ----------------------------- Save this password, it will not be displayed again. 验证PDS ...

十月 28, 2024 · JQX