Python3上的Scipy安装
我正在运行Linux Ubuntu 16.04 LTS。我安装了pip以加载Python的第三方包。 Python 2.7和3.5.2附带了我的Linux发行版,但后来我安装了3.6。现在我正在尝试安装Scipy。在scipy.org以下为SciPy的堆叠安装的说明,我跑以下命令(以前的PIP安装后)在终端:Python3上的Scipy安装
pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
问题是,这只是安装包的Python 2.7,而不是3.5.2或3.6。我如何使安装程序适用于Python 3.x?非常感谢指导。我的头发在这方面变得灰暗,我似乎无法通过谷歌搜索获得正确的结果。
我可以推荐Anaconda吗? https://www.continuum.io/
Anaconda(又名Conda)是一款支持Windows,Mac和Linux的跨平台软件包管理器。它旨在解决其他软件包管理器的问题(例如,易于安装,点,distutils)。
康达解决了很多包装问题。安装Conda后,您可以安装所需的软件包,而不用担心它们失败。您还可以创建“虚拟环境”。你想Python2和Python3在同一个系统上?完成。
conda create -n Python2 python=2.7.13
conda create -n Python3 python=3.6.0
要切换到一个,您可以键入:
activate Python2
现在你在Python2环境。
无论你喜欢什么,你都可以调用环境。
这是一个非常有用的20分钟视频,来自Continuum的Aaron Meurer在SciPy 2014上对Conda进行了演示。(https://www.youtube.com/watch?v=UaIvrDWrIWM)我观看了这段视频,它永远改变了我的生活(关于Python环境和包装)。
随着康达,创造SciPy2和SciPy3环境:
>conda search scipy
Fetching package metadata ...........
scipy 0.11.0 np17py27_1 defaults
0.11.0 np16py27_1 defaults
0.11.0 np17py26_1 defaults
0.11.0 np16py26_1 defaults
0.12.0 np17py26_0 defaults
0.12.0 np17py33_0 defaults
0.12.0 np17py27_0 defaults
0.12.0 np16py27_p0 defaults [mkl]
0.12.0 np17py27_p0 defaults [mkl]
<<Truncated>>
0.18.0 np111py34_0 defaults
0.18.0 np111py35_0 defaults
0.18.0 np111py27_0 defaults
0.18.1 np111py35_0 defaults
0.18.1 np111py27_0 defaults
0.18.1 np111py36_0 defaults
0.18.1 np111py34_0 defaults
0.18.1 np112py27_1 defaults
0.18.1 np111py34_1 defaults
0.18.1 np112py36_1 defaults
0.18.1 np111py36_1 defaults
0.18.1 np112py35_1 defaults
* 0.18.1 np111py27_1 defaults
0.18.1 np111py35_1 defaults
>conda search python
Fetching package metadata ...........
python 2.6.8 5 defaults
2.6.8 6 defaults
2.6.9 0 defaults
2.6.9 1 defaults
2.7.3 2 defaults
<<Truncated>>
2.7.10 0 defaults
2.7.10 1 defaults
2.7.10 3 defaults
2.7.10 4 defaults
2.7.10 5 defaults
2.7.11 0 defaults
2.7.11 1 defaults
2.7.11 2 defaults
2.7.11 4 defaults
2.7.11 5 defaults
2.7.12 0 defaults
* 2.7.13 0 defaults
3.3.0 4 defaults
3.3.1 0 defaults
3.3.2 0 defaults
3.3.3 0 defaults
3.3.4 0 defaults
3.3.5 0 defaults
<<Truncated>>
3.5.1 0 defaults
3.5.1 1 defaults
3.5.1 2 defaults
3.5.1 4 defaults
3.5.1 5 defaults
3.5.2 0 defaults
3.6.0 0 defaults
>conda create -n SciPy2 python=2.7.13 scipy=0.18.1
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment D:\Applications\Anaconda\envs\SciPy2:
The following NEW packages will be INSTALLED:
mkl: 2017.0.1-0
numpy: 1.12.0-py27_0
pip: 9.0.1-py27_1
python: 2.7.13-0
scipy: 0.18.1-np112py27_1
setuptools: 27.2.0-py27_1
vs2008_runtime: 9.00.30729.5054-0
wheel: 0.29.0-py27_0
Proceed ([y]/n)? y
numpy-1.12.0-p 100% |###############################| Time: 0:00:00 10.88 MB/s
scipy-0.18.1-n 100% |###############################| Time: 0:00:00 13.49 MB/s
#
# To activate this environment, use:
# > activate SciPy2
#
# To deactivate this environment, use:
# > deactivate SciPy2
#
# * for power-users using bash, you must source
#
>conda create -n SciPy3 python=3.6.0 scipy=0.18.1
Fetching package metadata ...........
Solving package specifications: .
Package plan for installation in environment D:\Applications\Anaconda\envs\SciPy3:
The following NEW packages will be INSTALLED:
mkl: 2017.0.1-0
numpy: 1.12.0-py36_0
pip: 9.0.1-py36_1
python: 3.6.0-0
scipy: 0.18.1-np112py36_1
setuptools: 27.2.0-py36_1
vs2015_runtime: 14.0.25123-0
wheel: 0.29.0-py36_0
Proceed ([y]/n)? y
vs2015_runtime 100% |###############################| Time: 0:00:00 9.96 MB/s
python-3.6.0-0 100% |###############################| Time: 0:00:02 12.86 MB/s
numpy-1.12.0-p 100% |###############################| Time: 0:00:00 13.61 MB/s
setuptools-27. 100% |###############################| Time: 0:00:00 13.15 MB/s
wheel-0.29.0-p 100% |###############################| Time: 0:00:00 18.89 MB/s
pip-9.0.1-py36 100% |###############################| Time: 0:00:00 11.73 MB/s
scipy-0.18.1-n 100% |###############################| Time: 0:00:00 12.76 MB/s
#
# To activate this environment, use:
# > activate SciPy3
#
# To deactivate this environment, use:
# > deactivate SciPy3
#
# * for power-users using bash, you must source
#
>activate SciPy3
(SciPy3) >
注:我只是做这在Windows上。它在Mac和Linux上的工作原理是一样的,除非像它说的那样,使用Bash你必须先获得源代码才能激活。
我希望这可以帮助你,因为它帮助了我。
正如@Akavall提到的那样,目前您已经安装了Python2.x pip,并且当您运行此命令pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose
时,您正在使用此pip来安装软件包。为了安装Python3.x的软件包,您需要安装一个Python3.x pip,它被称为pip3。要安装PIP3,从终端运行下面的命令:
sudo apt-get install python3-pip
一旦PIP3已经安装,您可以使用再安装包为您python3.x:
pip3 install <module-name>
注意您仍然可以继续在同一台机器上同时运行Python2.x和Python3.x,因此不需要卸载python2.x。
您可以继续安装包Python2.x因为你一直在做,通过使用:
pip install <module-name>
和使用python3.x安装软件包:
pip3 install <module-name>
最后,要在您的终端上运行Python3.x,您需要输入:
python3
而不仅仅是python
(它是指python2.x
)。举例来说,如果你有一个名为Hello.py脚本,从终端使用Python3.x执行该脚本您执行以下操作:
python3.x Hello.py
使用Python2.x运行相同的脚本,你就以下:
python2.x Hello.py
或:
python Hello.py
所以,一句话,pip
点python2,惠斯特pip3
点python3。见this question for more information。
我希望能回答你的问题:)。再次,我只是扩展了@Akavall上面已经给出的一个好评,所以信誉归功于@Akavall。
我的荣幸,我很高兴能够帮到你:)。如果答案确实能解决您的问题,您可以将其标记为正确的答案 - 如果答案确实回答了您的问题,那就是。 –
你是否研究过为python3安装pip:'sudo apt-get install python3-pip',然后使用'pip3'(而不是'pip')来安装你的软件包? – Akavall
我建议您查看[virtualenv](https://virtualenv.pypa.io/en/stable/)或使用[Anaconda](https://www.continuum.io/downloads)并为您的不同版本创建环境蟒蛇 – Grr