windows下python3.6版本numpy,Scipy,matplotlib,sklearn,pandas安装

windows下python3.6版本numpy,Scipy,matplotlib,sklearn,pandas安装

系统是windows64位,安装了python3.6。

安装顺序就是numpy,Scipy,matplotlib,sklearn,pandas。
首先是更新一下pip (确保pip能使用)
然后将setuptools, numpy, python-dateutil, pytz, pyparsing, cycler,matplotlib分别代替最后的pip并运行

PS C:\Users\wenchaoz> python -m pip install --upgrade pip
Collecting pip
  Downloading pip-8.1.2-py2.py3-none-any.whl (1.2MB)
    100% |████████████████████████████████| 1.2MB 315kB/s
Installing collected packages: pip
  Found existing installation: pip 7.1.2
    Uninstalling pip-7.1.2:
      Successfully uninstalled pip-7.1.2
Successfully installed pip-8.1.2

PS C:\Users\wenchaoz> python -m pip install --upgrade numpy
Collecting numpy
  Downloading numpy-1.11.1-cp27-none-win_amd64.whl (7.4MB)
    100% |████████████████████████████████| 7.4MB 138kB/s
Installing collected packages: numpy
  Found existing installation: numpy 1.9.2
    DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future
version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling numpy-1.9.2:
      Successfully uninstalled numpy-1.9.2
Successfully installed numpy-1.11.1

PS C:\Users\wenchaoz> python -m pip install --upgrade pytz
Collecting pytz
  Downloading pytz-2016.6.1-py2.py3-none-any.whl (481kB)
    100% |████████████████████████████████| 481kB 1.2MB/s
Installing collected packages: pytz
Successfully installed pytz-2016.6.1

PS C:\Users\wenchaoz> python -m pip install --upgrade pyparsing
Collecting pyparsing
  Downloading pyparsing-2.1.5-py2.py3-none-any.whl (42kB)
    100% |████████████████████████████████| 51kB 122kB/s
Installing collected packages: pyparsing
Successfully installed pyparsing-2.1.5

PS C:\Users\wenchaoz> python -m pip install --upgrade cycler
Collecting cycler
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Requirement already up-to-date: six in c:\python27\lib\site-packages (from cycler)
Installing collected packages: cycler
Successfully installed cycler-0.10.0

PS C:\Users\wenchaoz> python -m pip install --upgrade matplotlib
Collecting matplotlib
  Downloading matplotlib-1.5.1-cp27-none-win_amd64.whl (6.1MB)
    100% |████████████████████████████████| 6.1MB 167kB/s
Requirement already up-to-date: cycler in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: pytz in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: pyparsing!=2.0.4,>=1.5.6 in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: numpy>=1.6 in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: python-dateutil in c:\python27\lib\site-packages (from matplotlib)
Requirement already up-to-date: six in c:\python27\lib\site-packages (from cycler->matplotlib)
Installing collected packages: matplotlib
  Found existing installation: matplotlib 1.5.0
    Uninstalling matplotlib-1.5.0:
      Successfully uninstalled matplotlib-1.5.0
Successfully installed matplotlib-1.5.1

PS C:\Users\wenchaoz> python -m pip install --upgrade sklearn
...
PS C:\Users\wenchaoz> python -m pip install --upgrade pandas

查看安装的库:pip list

在这里插入图片描述

几个报错点,看看对你们有没有帮助:
  • 在安装matplotlib的时候报错了(报错没截图,不好意思)
       一开始我先试着安装了lxml ( python -m pip install --upgrade lxml),再安装matplotlib,结果仍然报错
    解决:
       先输入python -m pip install -U pip setuptools进行升级,再安装matplotlib就成功了(还不行,就重启电脑再试一下)

  • 更新pip的时候报错
    如下:
       Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: ‘d:\develop\python\python36\lib\site-packages\pip-18.1.dist-info\entry_po ints.txt’ Consider using the --user option or check the permissions.
    解决:
    将python -m pip install --upgrade pip
    改成python -m pip install --user --upgrade pip

  • 直接打开命令窗口输入上面那些命令报错的
    可以试试进入python的这个目录再输入命令安装:
    在这里插入图片描述

主要参考:
https://www.cnblogs.com/Deribs4/p/6366217.html
https://blog.csdn.net/saltedfish_mountain/article/details/79135594

  • 0
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,以下是一个使用numpymatplotlibpandasscipy库进行多元线性回归的示例代码: ```python import numpy as np import matplotlib.pyplot as plt import pandas as pd from scipy import stats # 读取CSV文件 data = pd.read_csv('data.csv') # 将数据转换为numpy数组 x = data.iloc[:, :-1].values y = data.iloc[:, -1].values # 计算相关系数矩阵 r = np.corrcoef(x.T) # 计算特征值和特征向量 eig_vals, eig_vecs = np.linalg.eig(r) # 取最大的k个特征值对应的特征向量组成投影矩阵 k = 2 proj_mat = eig_vecs[:, :k] # 将数据降维到k维 x_pca = x.dot(proj_mat) # 添加一列全为1的向量作为截距 x_pca = np.hstack((np.ones((x_pca.shape[0], 1)), x_pca)) # 计算最小二乘解 beta = np.linalg.inv(x_pca.T.dot(x_pca)).dot(x_pca.T).dot(y) # 输出回归系数 print('回归系数为', beta) # 绘制回归直线 plt.scatter(x_pca[:, 1], y) x_line = np.linspace(np.min(x_pca[:, 1]), np.max(x_pca[:, 1]), 100) y_line = beta[0] + beta[1] * x_line plt.plot(x_line, y_line, color='red') plt.show() ``` 其中,data.csv文件格式如下所示: ``` x1,x2,y 1,2,5 2,3,7 3,4,9 4,5,11 5,6,13 ``` 代码首先读取CSV文件并将数据转换为numpy数组。然后,计算相关系数矩阵,并求出特征值和特征向量。接着,取最大的k个特征值对应的特征向量组成投影矩阵,将数据降维到k维,并添加一列全为1的向量作为截距。最后,计算最小二乘解,得到回归系数,并绘制回归直线。 上述代码仅仅是一个示例,您可以根据自己的需要进行修改和扩展。同时,需要注意的是,多元线性回归需要满足一些前提条件,如线性关系、正态分布、同方差性等,您需要在进行回归分析之前进行检验。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值