Skip to content

Commit 7d280b6

Browse files
committed
venv
1 parent ac134ba commit 7d280b6

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Python/Python.md

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ categories:
3232
- 3.1.1. [http](#http)
3333
- 3.1.2. [virtualenv](#virtualenv)
3434
- 3.1.3. [pip](#pip)
35-
- 3.1.3.1. [Requirements files](#requirements-files)
36-
- 3.1.3.2. [发布包到 pypi](#发布包到-pypi)
37-
- 3.1.4. [matplotlib](#matplotlib)
35+
- 3.1.3.1. [依赖管理](#依赖管理)
36+
- 3.1.3.2. [Requirements files](#requirements-files)
37+
- 3.1.3.3. [发布到pypi](#发布到pypi)
3838
- 3.2. [文件操作](#文件操作)
3939
- 3.2.1. [JSON](#json)
4040
- 3.2.2. [conf或者ini](#conf或者ini)
@@ -52,7 +52,7 @@ categories:
5252
- 3.7.2. [时间处理](#时间处理)
5353
- 3.7.3. [三方库](#三方库)
5454

55-
💠 2024-12-19 21:03:00
55+
💠 2024-12-26 11:42:45
5656
****************************************
5757
# Python
5858
> [Official Site](https://www.python.org/)
@@ -534,23 +534,18 @@ When importing the package, Python searches through the directories on `sys.path
534534
python -m module_name
535535

536536
### http
537-
- 快速启动一个 HTTP Web 服务器 `http.server [port]`
537+
- 快速启动一个 HTTP Web 服务器 `python -mhttp.server [port]`
538538

539539
### virtualenv
540-
> [廖雪峰 virtualenv](https://www.liaoxuefeng.com/wiki/0014316089557264a6b348958f449949df42a6d3a2e542c000/001432712108300322c61f256c74803b43bfd65c6f8d0d0000)
541540

542-
**虽然也可以用apt安装 python-venv, 但是最好不要这样,避免后续模块升级后不必要的冲突**
543-
544-
- 创建环境 `python3 -m venv web` 或者 `virtualenv --no-site-packages web` 不将系统中安装的包带入该环境
541+
- 创建环境 `python3 -m venv web`
545542
- 启动环境 `source web/bin/activate`
546-
- 在环境中使用的pip python 都是环境中的, 其实就是修改了系统的环境变量指向
543+
- 在环境中使用的pip python命令都是web目录下的, 其实就是修改了系统的环境变量指向
547544
- 停用环境 `deactivate`
548545

549546
### pip
550547
> [pip](https://pip.readthedocs.io/en/stable/) | [doc](https://pip.pypa.io/en/stable/reference/pip_install/) | [guide](https://packaging.python.org/tutorials/installing-packages/)
551548
552-
> [uv](https://docs.astral.sh/uv/) Rust实现的包管理
553-
554549
1. 作为Python的包管理器, 包的可执行文件默认在 /usr/local/bin 目录下(全局)
555550
- 如果安装时加了该参数 --user 就是安装在 ~/.local/bin 目录下
556551

@@ -568,11 +563,14 @@ python -m module_name
568563
- 可以设置默认全局 python3 -m pip config set global.break-system-packages true
569564
- 或者单次安装到全局 --break-system-packages
570565

571-
> 3.10 后 pip 作为子模块
566+
> 3.10 后 pip 作为子模块使用
572567
- 安装 `python -m ensurepip --upgrade`
573568
- 使用 `python -m pip install pkgName`
574569
- 升级 `python -m pip install --upgrade pip`
575570

571+
#### 依赖管理
572+
当发现环境内一个包有多个版本时,可以通过直接打开python解释器,import包,执行 包名._version 查看, 例如 `pandas._version``pandas.__version__`
573+
576574
#### Requirements files
577575
> [pip官方文档 Requirements files](https://pip.readthedocs.io/en/1.1/requirements.html)
578576
@@ -582,7 +580,7 @@ python -m module_name
582580

583581
1. 使用 `pip install -r requirements.txt`
584582

585-
#### 发布包到 pypi
583+
#### 发布到pypi
586584
> [Official : about package](https://packaging.python.org/guides/distributing-packages-using-setuptools/?highlight=pypirc#id78)
587585
588586
1. edit `$HOME/.pypirc` to save authorization info
@@ -602,11 +600,8 @@ python -m module_name
602600
> 1. pip install collective.checkdocs Pygments
603601
> 1. python3 setup.py checkdocs
604602
605-
### matplotlib
606-
607603
************************
608604
609-
610605
## 文件操作
611606
612607
- 注意路径,Windows系统中要使用反斜杠 \

Python/Readme.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434
> 问题
3535
- [Undefined symbol libgssapi_krb5.so.2 / Newbie Corner / Arch Linux Forums](https://bbs.archlinux.org/viewtopic.php?id=292834) 不想浪费时间找原因,直接放弃 停用conda 要用多版本python时再临时去 zshrc 里启用
3636

37+
###
38+
[uv](https://docs.astral.sh/uv/) Rust实现的环境管理(Python版本,包管理等等)
39+
40+
uv venv --python 3.12.0
41+
3742
### sys.path
3843
> [Doc: Python path](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPATH)
3944

0 commit comments

Comments
 (0)