一.windows安装python
1.下载安装
首先要先下载安装包:Download Python | Python.org
网上建议下载python3.7.4版本,那就下载这个版本
2.验证
二.Ubuntu22.04安装python环境
1.python安装
ls -l /usr/bin | grep python
sudo apt-get install openssl
sudo apt-get install libssl-dev
cd /home
sudo wget https://www.python.org/ftp/python/3.10.6/Python-3.10.6.tgz
tar -zxvf Python-3.10.6.tgz
cd Python-3.10.6/
sudo ./configure --prefix=/usr/local/python3.10.6
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
sudo make
sudo make install
# 环境变量配置
PATH=$PATH:$HOME/bin:/usr/local/python3.10.6/bin
2.pip安装
# Python 3 安装 pip
sudo apt update
sudo apt install python3-pip
pip3 --version
$ pip --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
$ pip3 --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
$ pip3 --version
pip3 pip3.10
$ pip3.10 --version
pip 22.0.2 from /usr/lib/python3/dist-packages/pip (python 3.10)
3.pip镜像配置
~$ pip config list
~$ pip config list
~$ pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
Writing to /home/root/.config/pip/pip.conf
~$ pip config list
global.index-url='https://mirrors.aliyun.com/pypi/simple/'
4.pip安装测试 mysql、Oracle、sqlserver
要在 Python 中连接 MySQL、SQL Server 和 Oracle 数据库,你需要安装相应的数据库驱动程序。以下是连接这些数据库所需的驱动程序和依赖项:
### MySQL
1. **安装 MySQL 驱动程序**:你可以使用 `mysql-connector-python` 包来连接 MySQL 数据库。你可以通过以下命令安装该包:
```bash
pip install mysql-connector-python
```
2. **安装 MySQL 客户端**:在使用 `mysql-connector-python` 之前,确保你的系统中安装了 MySQL 客户端。你可以根据你的操作系统安装 MySQL 客户端。
### SQL Server
1. **安装 SQL Server 驱动程序**:你可以使用 `pyodbc` 包来连接 SQL Server 数据库。你可以通过以下命令安装该包:
```bash
pip install pyodbc
```
2. **安装 SQL Server 驱动**:在使用 `pyodbc` 之前,你需要安装适用于 SQL Server 的 ODBC 驱动程序。你可以在 Microsoft 官方网站上找到适用于你的操作系统的驱动程序。
### Oracle
1. **安装 Oracle 驱动程序**:你可以使用 `cx_Oracle` 包来连接 Oracle 数据库。安装该包需要一些额外的步骤:
- 首先,确保你的系统中已经安装了 Oracle 客户端。你可以从 Oracle 官方网站下载并安装适用于你的操作系统的 Oracle 客户端。
- 然后,你可以通过以下命令安装 `cx_Oracle` 包:
```bash
pip install cx_Oracle
```
二.pip
1.升级pip
pip 是 Python 的包管理工具,该工具提供了对Python 包的查找、下载、安装、卸载的功能
升级pip命令,使用国内地址
python -m pip install --user --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple
2.安装myqr
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple myqr
检查是否安装成功 :pip list
三.镜像地址
设置国内镜像
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
C:\Users\Administrator>pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Writing to C:\Users\Administrator\AppData\Roaming\pip\pip.ini
阿里云: http://mirrors.aliyun.com/pypi/simple/
中国科技大学: https://pypi.mirrors.ustc.edu.cn/simple/
豆瓣(douban): http://pypi.douban.com/simple/
清华大学: https://pypi.tuna.tsinghua.edu.cn/simple/
中国科学技术大学: http://pypi.mirrors.ustc.edu.cn/simple/
四.PyCharm社区版安装
Download PyCharm: The Python IDE for data science and web development by JetBrains