windows安装python3

环境

操作系统:windows 10

python版本:3.12.0

※(避坑)注意版本选择,发布博文时我选用了当时最新python版本3.12,在尝试通过pip安装mysqlclient模块时一直提示缺少c++ 14.0或更高版本,做出很多努力之后仍然安装失败,将python版本换成3.9或3.10后,重新执行“pip install mysqlclient”成功。

文件下载

Download Python | Python.org

安装

双击安装包,勾选使用管理员权限和添加环境变量,然后点击“Install Now”

等待安装完毕,点击“Close”

打开cmd命令行窗口,输入python --version查看python版本

C:\Users\49285>python --version
Python 3.12.0

pip配置国内源

# 临时使用
pip install package-name -i https://pypi.tuna.tsinghua.edu.cn/simple

# 永久配置
# 阿里源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
pip config set install.trusted-host mirrors.aliyun.com

# 清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple/
pip config set install.trusted-host pypi.tuna.tsinghua.edu.cn

示例:配置成阿里源

C:\Users\49285>pip config set global.index-url https://mirrors.aliyun.com/pypi/simple
Writing to C:\Users\49285\AppData\Roaming\pip\pip.ini

C:\Users\49285>pip config set install.trusted-host mirrors.aliyun.com
Writing to C:\Users\49285\AppData\Roaming\pip\pip.ini

命令执行完成后,C:\Users\49285\AppData\Roaming\pip\pip.ini内容如下:

[global]
index-url = https://mirrors.aliyun.com/pypi/simple

[install]
trusted-host = mirrors.aliyun.com

种草

我的博文内容主要针对“计算机网络”、“安全”、“运维”和“云计算”方向,感兴趣朋友的请关注我,我将不定期发布新的博文并不断改进已发布博文。

后期依据大家对博文的评论,点赞及关注情况,针对大家感兴趣的内容我也会录制视频并整理出成套的学习资料免费分享给大家,期待能和大家一起交流学习。

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Python链接MySQL驱动包,安装之后可以使用Python语言链接MySQL进行数据库操作 # mysqlclient [![Build Status](https://secure.travis-ci.org/PyMySQL/mysqlclient-python.png)](http://travis-ci.org/PyMySQL/mysqlclient-python) This is a fork of [MySQLdb1](https://github.com/farcepest/MySQLdb1). This project adds Python 3 support and bug fixes. I hope this fork is merged back to MySQLdb1 like distribute was merged back to setuptools. ## Install ### Prerequisites You may need to install the Python and MySQL development headers and libraries like so: `sudo apt-get install python-dev libmysqlclient-dev` # Debian / Ubuntu `sudo yum install python-devel mysql-devel` # Red Hat / CentOS On Windows, there are binary wheel you can install without MySQLConnector/C or MSVC. #### Note on Python 3 : if you are using python3 then you need to install python3-dev using the following command : `sudo apt-get install python3-dev` # debian / Ubuntu `sudo yum install python3-devel ` # Red Hat / CentOS `brew install mysql-connector-c` # macOS (Homebrew) ### Install from PyPI `pip install mysqlclient` NOTE: Wheels for Windows may be not released with source package. You should pin version in your `requirements.txt` to avoid trying to install newest source package. ### Install from source 1. Download source by `git clone` or [zipfile](https://github.com/PyMySQL/mysqlclient-python/archive/master.zip). 2. Customize `site.cfg` 3. `python setup.py install` ### Documentation Documentation is hosted on [Read The Docs](https://mysqlclient.readthedocs.io/)

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

hougang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值