NumPy in Python 2.7.3, Python 3.6.4 Different versions of the application __python

Source: Internet
Author: User
Tags stdin win32 install pandas continuum analytics install matplotlib lenovo

NumPy in Python 2.7.3, Python 3.6.4 Different versions of the application

1, install Anaconda, install the default Python environment created when Anaconda, the environment name is root, the corresponding Python version is 3.6.4

2, using NumPy, error printing print, Python 3.6 printing to add parentheses.

To facilitate numpy testing, create a Python 2.7.3 environment and use NumPy in python2.7.3.

3, create the use environment for Python 2.7.3 in Anaconda.

c:\users\lenovo>conda--version conda 4.3.30 c:\users\lenovo>conda Info--envs # Conda Environments: # root * G:\ProgramData\Anaconda3 C:\users\lenovo>conda create--name python27 python
=2.7 fetching package metadata ..... ......

Solving Package Specifications:.

Package. Installation in Environment G:\ProgramData\Anaconda3\envs\python27: .....

C:\users\lenovo>python--version python 3.6.4:: Anaconda, Inc. C:\users\lenovo>activate python27 (python27) C:\users\lenovo>python--version python 2.7.13:: Continuum

Analytics, Inc. (PYTHON27)

C:\users\lenovo>deactivate python27 c:\users\lenovo>python--version python 3.6.4:: Anaconda, Inc. C:\users\lenovo>activate python27 (python27) C:\users\lenovo>python Python 2.7.13 | Continuum Analytics, inc.| (default, May 11 2017, 13:17:26) [MSC v.1500-bit (AMD64)] on Win32 if the PYTHON27 environment you just added is no longer in use, you can delete 
by executing the command: Conda remove--name python27.--all

4, in the Python 2.7.3 environment load NumPy error, NumPy has not been installed.

5, install NumPy, scipy, pandas, matplotlib packages in the Python 2.7.3 environment.

python-m pip install--upgrade pip
pip install numpy
pip install scipy
pip install pandas
pip install Mat Plotlib

6, the execution of the NumPy method was successful.


Microsoft Windows [version 10.0.15063] (c) 2017 Microsoft Corporation.

All rights reserved. C:\users\lenovo>python Python 3.6.4 | Anaconda, inc.| (default, 16 2018, 10:22:32)
[MSC v.1900-bit (AMD64)] on Win32 Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information. >>> import Timeit >>> >>> common_for = "" "... for D in data: ... S + = d ... "" ">>> >>> common_sum =" "... sum (data) ... "" ">>> >>> common_numpy_sum =" "... numpy.sum (data) ... "" >>> >>> def timeit_list (n, loops): ... list_setup = "" ... import numpy ... data = [1] * {}. . s = 0 ... ' "'. Format (n) ... print ' list: ' File ' <stdin> ', line 7 print ' list: ' ^ syntaxerror:missin G parentheses in call to ' print '.
 

Did you mean print (int ' list: ')?
C:\users\lenovo>conda Create--name python27 python=2.7 fetching Package .........

Solving Package Specifications:. Package Plan for INstallation in Environment g:\programdata\anaconda3\envs\python27:the following NEW packages'll be Installed:cer      Tifi:2016.2.28-py27_0 Https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free Pip:9.0.1-py27_1 Https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free python:2.7.13-1 Https://mirrors.tuna.tsin Ghua.edu.cn/anaconda/pkgs/free Setuptools:36.4.0-py27_1 HTTPS://MIRRORS.TUNA.TSINGHUA.EDU.CN/ANACONDA/PKGS/FR EE vc:9-0 https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free vs2008_runtime:9.00. 30729.5054-0 Https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free wheel:0.29.0-py27_0 https://mirrors . Tuna.tsinghua.edu.cn/anaconda/pkgs/free Wincertstore:0.2-py27_0 Https://mirrors.tuna.tsinghua.edu.cn/anacon Da/pkgs/free proceed ([y]/n)? Y vs2008_runtime 100% |###############################| time:0:00:00 3.03 MB/s vc-9-0.tar.bz2 100% |###############################| time:0:00:00 729.58 kb/s python-2.7.13-100% |###############################| time:0:00:03 8.20 mb/s certifi-2016.2 100% |###############################| time:0:00:00 3.34 MB/s wheel-0.29.0-p 100% |###############################| time:0:00:00 4.43 MB/s wincertstore-0 100% |###############################| time:0:00:00 7.10 mb/s setuptools-36. 100% |###############################| time:0:00:00 2.93 MB/s pip-9.0.1-py27 100% |###############################| time:0:00:00 7.38 MB/s # to activate-environment, use: # > Activate python27 # to deactivate an active envi 
Ronment, use: # > Deactivate # * for power-users using bash, your must source # C:\users\lenovo>conda info--envs # Conda environments: # python27 G:\ProgramData\Anaconda3\envs\python27 root * G:\Progr

Amdata\anaconda3 C:\users\lenovo>python--version python 3.6.4:: Anaconda, Inc. C:\users\lenovo>activate python27 (pythonC:\users\lenovo>python--version python 2.7.13:: Continuum Analytics, Inc. (PYTHON27)

C:\users\lenovo>deactivate python27 c:\users\lenovo>python--version python 3.6.4:: Anaconda, Inc. C:\users\lenovo>activate python27 (python27) C:\users\lenovo>python Python 2.7.13 | Continuum Analytics, inc.| (default, May 11 2017, 13:17:26)
[MSC v.1500-bit (AMD64)] on Win32 Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information.
Anaconda is brought to your by Continuum Analytics. Please check out:http://continuum.io/thanks and https://anaconda.org >>> >>> >>> >>
> >>> >>> import timeit >>> >>> common_for = "" ... for D in data:. S + = d ... "" ">>> >>> common_sum =" "... sum (data) ... "" ">>> >>> common_numpy_sum =" "... numpy.sum (data) ... "" >>> >>> def timeit_list (n, loops): ... list_setup = "" ... import numpy ...data = [1] * {} ... s = 0 ... ' "'. Format (n) ... print ' list: ' ... print Timeit.timeit (common_for, list_setup, number = loops) ... print time It.timeit (Common_sum, list_setup, number = loops) ... print Timeit.timeit (common_numpy_sum, list_setup, number = Loops ) ... >>> def timeit_array (n, loops): ... array_setup = "" "... import numpy ... data = Arra Y.array (' L ', [1] * {}) ... s = 0 ... ' "'. Format (n) ... print ' array: ' ... print Timeit.timeit (common_for, array_setup, number = loops) ... print ti Meit.timeit (Common_sum, array_setup, number = loops) ... print Timeit.timeit (common_numpy_sum, array_setup, number = L  Oops) ... >>> def timeit_numpy (n, loops): ... numpy_setup = "" ... import numpy ... data = Numpy.array ([1] * {}) ... s = 0 ... ' "'. Format (n) ... print ' NumPy: ' ... print Timeit.timeit (common_for, numpy_setup, number = loops) ... print ti    Meit.timeit (Common_sum, numpy_setup, number = loops) ... Print Timeit.timeit (common_numpy_sum, numpy_setup, number = loops) ... >>> if __name__ = = ' __main__ ': Ti Meit_list (50000) ... timeit_array (50000) ... timeit_numpy (50000, +) ... list:traceback (most recent C All last): File "<stdin>", line 2, in <module> file "<stdin>", line 8, in timeit_list file "G:\Pro
  gramdata\anaconda3\envs\python27\lib\timeit.py ", line 237, in Timeit return Timer (stmt, Setup, timer). Timeit (number)
  File "G:\ProgramData\Anaconda3\envs\python27\lib\timeit.py", line, Timeit timing = Self.inner (it, Self.timer)  File "<timeit-src>", line 4, in inner importerror:no module named numpy >>> import NumPy traceback (most





Recent call last): File "<stdin>", line 1, in <module> importerror:no module named NumPy >>> ^c (PYTHON27)  C:\users\lenovo>pip Install numpy collecting numpy downloading NUMPY-1.14.2-CP27-NONE-WIN_AMD64.WHL (13.3MB) 100% |████████████████████████████████|  13.3MB 31kb/s Installing collected packages:numpy successfully installed numpy-1.14.2 Cache entry deserialization failed,
Entry ignored you are the using PIP version 9.0.1, however version 9.0.3 is available.

You should consider upgrading via the ' python-m pip install--upgrade pip ' command. (PYTHON27) C:\users\lenovo>pip Install scipy collecting scipy downloading SCIPY-1.0.1-CP27-NONE-WIN_AMD64.WHL (31.2MB) 100% |████████████████████████████████| 31.2MB 20kb/s requirement already satisfied:numpy>=1.8.2 in g:\programdata\anaconda3\envs\python27\lib\ Site-packages (from scipy) installing collected packages:scipy successfully installed scipy-1.0.1 you are using PIP Versi
On 9.0.1, however version 9.0.3 is available.

You should consider upgrading via the ' python-m pip install--upgrade pip ' command. (PYTHON27) C:\users\lenovo>pip Install pandas collecting pandas downloading PANDAS-0.22.0-CP27-CP27M-WIN_AMD64.WHL (9.1MB) 1 0% |████████████████████████████████| 9.1MB 44kb/s collecting pytz>=2011k (from pandas) downloading PYTZ-2018.3-PY2.PY3-NONE-ANY.WHL (509kB) 100% |████ ████████████████████████████| 512kB 57kb/s requirement already satisfied:numpy>=1.9.0 in g:\programdata\anaconda3\envs\python27\lib\ Site-packages (from Pandas) collecting python-dateutil (from pandas) downloading Python_ DATEUTIL-2.7.2-PY2.PY3-NONE-ANY.WHL (212kB) 100% |████████████████████████████████|
215kB 95kb/s collecting six>=1.5 (from Python-dateutil->pandas) downloading SIX-1.11.0-PY2.PY3-NONE-ANY.WHL Installing collected Packages:pytz, six, Python-dateutil, pandas-successfully installed pandas-0.22.0 PYTHON-DATEUTIL-2
.7.2 pytz-2018.3 six-1.11.0 You are the using PIP version 9.0.1, however version 9.0.3 is available.

You should consider upgrading via the ' python-m pip install--upgrade pip ' command. (PYTHON27) C:\users\lenovo>pip Install matplotlib collecting matplotlib downloading4.WHL (8.4MB) 100% |████████████████████████████████| 8.4MB 33kb/s collecting Backports.functools-lru-cache (from matplotlib) downloading Backports.functools_lru_ CACHE-1.5-PY2.PY3-NONE-ANY.WHL collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from Matplotlib) Downloading PYPARSING-2.2.0-PY2.PY3-NONE-ANY.WHL (56kB) 100% |████████████████████████████████| 61kB 28kb/s requirement already satisfied:numpy>=1.7.1 in g:\programdata\anaconda3\envs\python27\lib\ Site-packages (from Matplotlib) collecting cycler>=0.10 (from matplotlib) downloading CYCLER-0.10.0-PY2.PY3-NONE-ANY.WHL collecting kiwisolver>=1.0.1 (from matplotlib) downloading KIWISOLVER-1.0.1-CP27-NONE-WIN_AMD64.WHL (64kB) 100% |████████████████████████████████| 71kB 41kb/s requirement already satisfied:python-dateutil>=2.1 in g:\programdata\anaconda3\envs\python27\lib\ Site-packages (from Matplotlib) requirement already satisfied:six>=1.10 in g:\programdata\anaconda3\envs\python27\ Lib\site-packages (from Matplotlib) requirement already satisfied:pytz in g:\programdata\anaconda3\envs\python27\lib\ Site-packages (from Matplotlib) requirement already satisfied:setuptools in g:\programdata\anaconda3\envs\python27\ Lib\site-packages (from Kiwisolver>=1.0.1->matplotlib) installing collected packages: Backports.functools-lru-cache, Pyparsing, Cycler, Kiwisolver, Matplotlib successfully installed backports.functools-lru-cache-1.5 cycler-0.10.0 kiwisolver-1.0.1 matplotlib-2.2.2 pyparsing-2.2.0 you are using PIP
Version 9.0.1, however version 9.0.3 is available.

You should consider upgrading via the ' python-m pip install--upgrade pip ' command. (PYTHON27)
  c:\users\lenovo>python-m pip install--upgrade pip Cache Entry deserialization failed, entry ignored collecting PIP Cache Entry deserialization failed, entry ignored downloading PIP-9.0.3-PY2.PY3-NONE-ANY.WHL (1.4MB) 100% |█████████ ███████████████████████| 1.4MB 79kb/s Installing collected Packages:pip Found existing INSTALLATION:PIP 9.0.1 uninstalling pip-9.0.1:successfully uninstalled pip-9.0.1 successfully Inst alled pip-9.0.3 (python27) C:\users\lenovo>python Python 2.7.13 | Continuum Analytics, inc.| (default, May 11 2017, 13:17:26)
[MSC v.1500-bit (AMD64)] on Win32 Type ' help ', ' copyright ', ' credits ' or ' license ' for the more information.
Anaconda is brought to your by Continuum Analytics. Please check out:http://continuum.io/thanks and https://anaconda.org >>> >>> import Timeit >>&
Gt >>> common_for = "" "... for D in data: ... s = + D ... "" ">>> >>> common_sum =" "... sum (data) ... "" ">>> >>> common_numpy_sum =" "... numpy.sum (data) ... "" >>> >>> def timeit_list (n, loops): ... list_setup = "" ... import numpy ... data = [1] * {}. . s = 0 ... ' "'. Format (n) ... print ' list: ' ... print Timeit.timeit (common_for, list_setup, number = loops) ... print time It. Timeit (Common_sum, list_setup, number = loops) ... print Timeit.timeit (common_numpy_sum, list_setup, number = loops) ... >>> def timeit_array (n, loops): ... array_setup = "" "... import numpy ... data = array. Array (' L ', [1] * {}) ... s = 0 ... ' "'. Format (n) ... print ' array: ' ... print Timeit.timeit (common_for, array_setup, number = loops) ... print ti Meit.timeit (Common_sum, array_setup, number = loops) ... print Timeit.timeit (common_numpy_sum, array_setup, number = L  Oops) ... >>> def timeit_numpy (n, loops): ... numpy_setup = "" ... import numpy ... data = Numpy.array ([1] * {}) ... s = 0 ... ' "'. Format (n) ... print ' NumPy: ' ... print Timeit.timeit (common_for, numpy_setup, number = loops) ... print ti Meit.timeit (Common_sum, numpy_setup, number = loops) ... print Timeit.timeit (common_numpy_sum, numpy_setup, number = L Oops) ... >>> if __name__ = = ' __main__ ': ... timeit_list (50000, +) ... TiMeit_array (50000) ... timeit_numpy (50000) ... list:0.944630636958 0.132346823532 1.1896890924 array:1.8873 3700807 1.22107083901 4.84144049432 numpy:3.09788283824 2.42338712602 0.0146385004209 >>>




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.