https://github.com/singcl/pypy
Python. Python之路.
https://github.com/singcl/pypy
python27 python3
Last synced: 1 day ago
JSON representation
Python. Python之路.
- Host: GitHub
- URL: https://github.com/singcl/pypy
- Owner: singcl
- Created: 2018-07-24T02:03:54.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T20:51:48.000Z (over 3 years ago)
- Last Synced: 2025-01-03T13:19:27.854Z (over 1 year ago)
- Topics: python27, python3
- Language: Python
- Homepage:
- Size: 1.05 MB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Python
Python 之路
_The way to Python._
## Windows 安装 Python38(Python27 同理)
1. 官网下载 python`https://www.python.org/downloads/`
2. 自定义安装 Python 到 C:/Python38
3. 设置环境变量:PYTHON_HOME: C:/Python38
4. Path 中添加: ;%PYTHON_HOME%;%PYTHON_HOME%\Scripts
## virtualenv 安装 Py2 Py3
```sh
# 安装virtualenv
pip install virtualenv
# Python27 虚拟环境
virtualenv -p C:/Python27/python.exe py2
# Python3x 虚拟环境
virtualenv -p C:/Python3x/python.exe py3
# activate in cmd
cd py3/Scripts/
activate
# activate in bash
source ./py3/Scripts/activate
# bash 查看当前python位置
which python
```
如果*source ./py3/Scripts/activate* 切换环境无效的话,删除虚拟环境再重新新建虚拟环境
## Vscode 中使用 virtualenv
https://segmentfault.com/q/1010000011089735
```sh
# PyCryptodome is a self-contained Python package of low-level cryptographic primitives.
# It supports Python 2.6 and 2.7, Python 3.4 and newer, and PyPy.
# All modules are installed under the Crypto package.
#You can install it with:
pip install pycryptodome
# 如果之前安装过crypto 模块的话先卸载crypto在手动删除site-packages 下的crypto文件 在安装pycryotodome
# 不然会安装失败
```
#生成 requirements.txt
python 项目中必须包含一个 requirements.txt 文件,用于记录所有依赖包及其精确的版本号。以便新环境部署。
```sh
# 自动生成
(venv) $ pip freeze > requirements.txt
# 安装
(venv) $ pip install -r requirements.txt
```
```python
#获取当前文件的绝对路径直接
# os.path.abspath(__file__)
# 获取当前文件夹所在的路径 直接
# os.path.dirname(os.path.abspath(__file__))
pic = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'mm.png')
```
### ValueError: too many file descriptors in select()错误和解决
因为 asyncio 内部用到了 select,而 select 就是系统打开文件数是有限度的,
这个其实是操作系统的限制,linux 打开文件的最大数默认是 1024,windows 默认是 509,超过了这个值,程序就开始报错
解决:限制并发量: semaphore = asyncio.Semaphore(100); async with semaphore:
详情查看`pypy\m3u8_downloader\src\async_m3u8_downloader.py`