二 查究的导火线
Tagged Tags:

目录

前言

一 管理虚构情状软件

  1.1 Mac Python管理虚构情形软件安装-Pyenv具体的流水生产线

  1.2 Mac Python管理虚构景况软件设置-Anaconda具体的流程

  1.3 Mac Python管理设想情状软件安装-pip具体的流水生产线

二 查究的导火线

  2.1 具体的标题(报错)

  2.2 先反省Python的安装与渠道

  2.3 安装包——Numpy

  2.4 安装包——matplotlib

  2.5 安装包——scipy

  2.6 安装pandas

  2.7 安装TensorFlow 

 

 

 

前言

世家要在支付中,使用两个python版本的,猛烈提出使用设置管理器www.yabovip4.com,工具管理虚构情状,不然就能够冒出以下一多元报错。由此会教你什么设置Python的
pandas等每一样包。

安装brew,设置教程。我们透过brew能够飞速实惠的下载我们供给的每一类软件,包含pyenv,Anaconda,virtualenv(设想情状)等。大家通过以下渠道来变成python包的治本:

 

1.
Anaconda:安装pandas、Python和SciPy最简便的艺术是用Anaconda。Anaconda是关于Python数据分析和科学总计的分签发承包合约。

  1. Miniconda
    利用Anaconda会安装一百八个依附包,假设想灵活决定装置的重视性包或带宽有限,使用Miniconda是个正确的选项。
    Conda是个包管理器,Anaconda正是树立在它的基础上。Conda不只跨平台还与语言无关,与pip和virtualenv相结合的成效相似。
    Miniconda允许先成立包括Python的安装包,然后用conda安装任何的重视包。

 

  1. pip
    pandas能够经过pip安装,但要安装相关的正视包。
    [plain] view plain copy
    pip install pandas

 

  1. 包管理器
    能够用linux的包管理器举办安装,如
    [plain] view plain copy
    sudo apt-get install python-pandas 
    zypper in python-pandas

 

  1. 源码安装
    从源码安装需求安装新型的Cython,可用easy-install -U
    cython安装。源码位于

[plain] view plain copy
git clone git://github.com/pydata/pandas.git 
cd pandas 
python setup.py install

 

 

 

一 管理虚构意况软件

1.1 Mac Python管理设想情状软件设置-Pyenv具体的流水生产线

1 先安装管理软件pyenv

村办安装新闻

 

87:~ jss$ brew install pyenv

Updating Homebrew…

==> Auto-updated
Homebrew!

Updated 1 tap (homebrew/core).

==> Updated
Formulae

app-engine-java  
  geth                lorem class=”Apple-converted-space”>             
radare2

bit              
  getmail             mapnik class=”Apple-converted-space”>             
roswell

calabash         
  gtk+                node class=”Apple-converted-space”>               
s-nail

cayley           
  gutenberg           node@4 class=”Apple-converted-space”>             
sassc

conan            
  gxml                node@6 class=”Apple-converted-space”>             
saxon

diffuse          
  heroku              node@8 class=”Apple-converted-space”>             
spigot

django-completion class=”Apple-converted-space”>  igv class=”Apple-converted-space”>                nspr class=”Apple-converted-space”>               
syncthing

docfx            
  jbake               odpi class=”Apple-converted-space”>               
tile38

flow             
  jenkins             onetime
           
yaml-cpp

fluent-bit       
  just                openimageio
       
yarn

flyway           
  kerl               
php

fn               
  libsass            
plank

 

==> Installing dependencies for
pyenv:
autoconf**, class=”s3″>pkg-config**, class=”s3″>openssl**, class=”s3″>readline**

==> Installing pyenv
dependency:
autoconf

==> Downloading

class=”s1″>########################################################################
100.0%

==> Pouring
autoconf-2.69.high_sierra.bottle.4.tar.gz

==> Caveats

Emacs Lisp files have been installed to:

 
/usr/local/share/emacs/site-lisp/autoconf

==> Summary

🍺 
/usr/local/Cellar/autoconf/2.69: 71 files, 3.0MB

亚搏app官方网站,==> Installing pyenv
dependency:
pkg-config

==> Downloading

class=”s1″>########################################################################
100.0%

==> Pouring
pkg-config-0.29.2.high_sierra.bottle.tar.gz

🍺 
/usr/local/Cellar/pkg-config/0.29.2: 11 files, 627.2KB

==> Installing pyenv
dependency:
openssl

==> Downloading
.

class=”s1″>########################################################################
100.0%

==> Pouring
openssl-1.0.2n.high_sierra.bottle.tar.gz

==> Caveats

A CA file has been bootstrapped using certificates
from the SystemRoots

keychain. To add additional certificates (e.g. the
certificates added in

the System keychain), place .pem files in

 
/usr/local/etc/openssl/certs

 

and run

 
/usr/local/opt/openssl/bin/c_rehash

 

This formula is keg-only, which means it was not
symlinked into /usr/local,

because Apple has deprecated use of OpenSSL in favor
of its own TLS and crypto libraries.

 

If you need to have this software first in your PATH
run:

  echo ‘export
PATH=”/usr/local/opt/openssl/bin:$PATH”‘ >>
~/.bash_profile

 

For compilers to find this software you may need to
set:

    LDFLAGS: class=”Apple-converted-space”> 
-L/usr/local/opt/openssl/lib

    CPPFLAGS:
-I/usr/local/opt/openssl/include

For pkg-config to find this software you may need to
set:

   
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig

 

==> Summary

🍺 
/usr/local/Cellar/openssl/1.0.2n: 1,792 files, 12.3MB

==> Installing pyenv
dependency:
readline

==> Downloading

class=”s1″>########################################################################
100.0%

==> Pouring
readline-7.0.3_1.high_sierra.bottle.tar.gz

==> Caveats

This formula is keg-only, which means it was not
symlinked into /usr/local,

because macOS provides the BSD libedit library, which
shadows libreadline.

In order to prevent conflicts when programs look for
libreadline we are

defaulting this GNU Readline installation to
keg-only..

 

For compilers to find this software you may need to
set:

    LDFLAGS: class=”Apple-converted-space”> 
-L/usr/local/opt/readline/lib

    CPPFLAGS:
-I/usr/local/opt/readline/include

 

==> Summary

🍺 
/usr/local/Cellar/readline/7.0.3_1: 46 files, 1.5MB

==> Installing class=”s3″>pyenv

==> Downloading

class=”s1″>########################################################################二 查究的导火线。
100.0%

==> Pouring
pyenv-1.2.2.high_sierra.bottle.tar.gz

🍺 
/usr/local/Cellar/pyenv/1.2.2: 593 files, 2.4MB

 

2 安装后增加景况变量,在terminal中输入

 

 sudo vi ~/.bash_profile

 

3 填写的切实可行变量内容

(个人消息:修改后备份 export PATH=${PATH}:/usr/local/mysql/bin )

 

export PYENV_ROOT=/usr/local/var/pyenv

if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi

 

4 使意况变量生效,必要使蒙受变量生效,运营命令

 

. ~/.bash_profile 

#或者

source ~/.bash_profile

 

本子切换

 

 

 

参考:

❌   -简书/Mac
OSX下Python多版本管理器pyenv的安装及利用

   -csdn/Mac多Python版本共存,多少个独立Python开采情状切换。 

 

 

 

1.2 Mac Python管理设想意况软件设置-Anaconda具体的流程 

a Anaconda简介

下一场正是多措施安装包可能模块。当中优先conda,其次pip,再度

conda下载的是二进制,pip有的会下载源码编写翻译

Anaconda软件集成了成都百货上千python的库,满含pandas,用python做多少分析的不胜枚进士都用那个

 

Anaconda
是一个用来科学计算的Python发行版,帮助 Linux, Mac,
Windows系统,提供了包管理与碰到管理的功用,能够很方便地消除多版本python并存、切换以及种种第三方包安装难题。

Anaconda利用工具/命令conda来扩充package和environment的田间管理,何况已经满含了Python和相关的配套工具。
这里先表明下conda、anaconda那一个概念的反差。是贰个封装的成团,里面预装好了conda、某些版本的python、众多packages、科学总计工具等等,所以也叫做Python的一种发行版。

conda能够理解为贰个工具,也是三个可试行命令,其主导职能是包处理与景况管理。包管理与pip的使用类似,情形管理则允许客商方便地设置区别版本的python并能够一点也不慢切换。

 

Anaconda使用格局

 

参考:

   - csdn/Anaconda的装置与安顿/镜像的布局

   -cnblog/python
安装anaconda, numpy, pandas, matplotlib 等/terminal
conda的操作与镜像的布署

   -天涯论坛/怎么着优雅的装置Python的pandas?

   -简书/Anaconda使用计算

   -csdn/Mac OS下
Anaconda Python2 和 Python3 配置/分界面简单介绍和python区别版本安装

   -cnblogs/Anaconda安装与意况陈设

 

 

 

1.3 Mac Python管理虚构蒙受软件安装-pip具体的流程 

1 优缺点

症结:下载速度慢,20180308安装中,下载速度介于20-50kb/s

优点:方便简单,没有供给太多的安装与操作 

www.yabovip4.com 1

 

2 查看已设置包列表 

 

#适用于mac中python2.x 版本
pip list  

 

#适用于mac中python3.x 版本
pip3 list

 

 

 

3 安装信赖包和模块

#适用于mac中python2.x 版本,xx是包名称
pip install xx  

 

#适用于mac中python3.x 版本,xx是包名称
pip3 install xx  

 

 

 

参考:

✅   -cnbolg/在
Mac OS X 上安装 TensorFlow 

    -简书/Python安装与版本管理/pip使用沙盒使用

 

 

二 探索的缘起

2.1 具体的主题素材(报错)

中途出家,调试代码中出现以下错误

Traceback (most recent call last):

  File “<stdin>”, line 1, in
<module>

ModuleNotFoundError: No module named ‘numpy’

 

Traceback (most recent call last):

  File “MLCNN.py”, line 8, in <module>

    import matplotlib.pyplot as plt

ModuleNotFoundError: No module named
‘matplotlib’

 

Traceback (most recent call last):

  File
“MLCNN.py”, line 9, in <module>

    import
scipy.io

ModuleNotFoundError: No module named ‘scipy’

 

Traceback (most recent call last):

  File
“MLCNN.py”, line 11, in <module>

    import
tensorflow as tf

ModuleNotFoundError: No module named
‘tensorflow’

 

Traceback (most recent call last):
File “MLCNN.py”, line 12, in <module>
import pandas as pd
ModuleNotFoundError: No module named ‘pandas’

 

 

 

 

2.2 先反省Python的本子与路径

1 查看python版本

#注意:‘-V‘中‘V’为大写字母,只有一个‘-’
python -V  

 

#注意:‘--version'中有两个‘-’
python --version 

 

2 查看python安装地点

python3以上的版本
注意print的时候使用的是括号,python3之下版本的无需括号

python -c "import sys; print (sys.executable)"

 

python -c "import os; print (os.sys.executable)" python -c "import os; path = os.sys.executable;folder=path[0 : path.rfind(os.sep)]; print folder"

 

 

 

2.3 安装包——Numpy(pip)

1 查看Numpy版本 

 

python -c "import numpy; print (numpy.version.version)"

python3 -c "import numpy; print (numpy.__version__)"

 

2 查看Numpy安装路线 

#python2.x版本
python -c "import numpy; print (numpy.__file__)"

python -c "import numpy; print (numpy.__file__)"

 

 

#python3.x版本
python3 -c "import numpy; print (numpy.__file__)"

python3 -c "import numpy; print (numpy.__file__)"

 

3 安装

$pip install –user numpy scipy matplotlib ipython jupyter pandas
sympy nose –prefix=~/local

 

4
将package安装到钦赐目录:通过源码安装贰个python包的时候,比如安装xlrd,目的路线为/usr/local/lib/python2.7/site-packages/

$ pip install -t /usr/local/lib/python2.7/site-packages/ xlrd

 

5
可能本人已经测验成功的,网站为

$mac os x: Python 3 安装(scipy,numpy,matplotlib. . .)

 

 

 

2.4 安装包——matplotlib

方法一 使用Pip

先安装pip,参考行业内部pip安装指令

curl -O

 

安装到Python2.7

二 查究的导火线。python get-pip.py

 

安装到Python3

python3 get-pip.py

二 查究的导火线。 

安装Matplotlib

二 查究的导火线。pip install matplotlib

 

报错:估量大概是因为几个版本产生的主题材料,小编的对象设置是python36,最终在本条论坛里找到消除方法。

Requirement already satisfied: matplotlib in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python

Requirement already satisfied: numpy>=1.5 in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(from matplotlib)

Requirement already satisfied: python-dateutil in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(from matplotlib)

Requirement already satisfied: tornado in
./Library/Python/2.7/lib/python/site-packages (from matplotlib)

Requirement already satisfied: pyparsing>=1.5.6 in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(from matplotlib)

Requirement already satisfied: nose in
./Library/Python/2.7/lib/python/site-packages (from matplotlib)

Requirement already satisfied: singledispatch in
./Library/Python/2.7/lib/python/site-packages (from
tornado->matplotlib)

Requirement already satisfied: certifi in
./Library/Python/2.7/lib/python/site-packages (from
tornado->matplotlib)

Requirement already satisfied: backports_abc>=0.4
in ./Library/Python/2.7/lib/python/site-packages (from
tornado->matplotlib)

Requirement already satisfied: six in
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
(from singledispatch->tornado->matplotlib)

我的pip list

DEPRECATION: The default format will switch to
columns in the future. You can use –format=(legacy|columns) (or
define a format=(legacy|columns) in your pip.conf under the [list]
section) to disable this warning.

altgraph (0.10.2)

appnope (0.1.0)

backports-abc (0.5)

backports.functools-lru-cache (1.5)

backports.shutil-get-terminal-size (1.0.0)

bdist-mpkg (0.5.0)

bleach (2.1.2)

bonjour-py (0.3)

certifi (2018.1.18)

configparser (3.5.0)

cycler (0.10.0)

decorator (4.2.1)

entrypoints (0.2.3)

enum34 (1.1.6)

functools32 (3.2.3.post2)

html5lib (1.0.1)

ipykernel (4.8.2)

ipython (5.5.0)

ipython-genutils (0.2.0)

ipywidgets (7.1.2)

Jinja2 (2.10)

jsonschema (2.6.0)

jupyter (1.0.0)

jupyter-client (5.2.2)

jupyter-console (5.2.0)

jupyter-core (4.4.0)

lxml (4.1.1)

macholib (1.5.1)

Markdown (2.6.9)

MarkupSafe (1.0)

matplotlib (2.1.2)

mistune (0.8.3)

modulegraph (0.10.4)

mpmath (1.0.0)

nbconvert (5.3.1)

nbformat (4.4.0)

nose (1.3.7)

notebook (5.4.0)

numpy (1.14.1)

pandas (0.22.0)

pandocfilters (1.4.2)

pathlib2 (2.3.0)

pexpect (4.4.0)

pickleshare (0.7.4)

pip (9.0.1)

prompt-toolkit (1.0.15)

ptyprocess (0.5.2)

py2app (0.7.3)

Pygments (2.2.0)

pyobjc-core (2.5.1)

pyobjc-framework-Accounts (2.5.1)

pyobjc-framework-AddressBook (2.5.1)

pyobjc-framework-AppleScriptKit (2.5.1)

pyobjc-framework-AppleScriptObjC (2.5.1)

pyobjc-framework-Automator (2.5.1)

pyobjc-framework-CFNetwork (2.5.1)

pyobjc-framework-Cocoa (2.5.1)

pyobjc-framework-Collaboration (2.5.1)

pyobjc-framework-CoreData (2.5.1)

pyobjc-framework-CoreLocation (2.5.1)

pyobjc-framework-CoreText (2.5.1)

pyobjc-framework-DictionaryServices (2.5.1)

pyobjc-framework-EventKit (2.5.1)

pyobjc-framework-ExceptionHandling (2.5.1)

pyobjc-framework-FSEvents (2.5.1)

pyobjc-framework-InputMethodKit (2.5.1)

pyobjc-framework-InstallerPlugins (2.5.1)

pyobjc-framework-InstantMessage (2.5.1)

pyobjc-framework-LatentSemanticMapping (2.5.1)

pyobjc-framework-LaunchServices (2.5.1)

pyobjc-framework-Message (2.5.1)

pyobjc-framework-OpenDirectory (2.5.1)

pyobjc-framework-PreferencePanes (2.5.1)

pyobjc-framework-PubSub (2.5.1)

pyobjc-framework-QTKit (2.5.1)

pyobjc-framework-Quartz (2.5.1)

pyobjc-framework-ScreenSaver (2.5.1)

pyobjc-framework-ScriptingBridge (2.5.1)

pyobjc-framework-SearchKit (2.5.1)

pyobjc-framework-ServiceManagement (2.5.1)

pyobjc-framework-Social (2.5.1)

pyobjc-framework-SyncServices (2.5.1)

pyobjc-framework-SystemConfiguration (2.5.1)

pyobjc-framework-WebKit (2.5.1)

pyOpenSSL (0.13.1)

pyparsing (2.2.0)

python-dateutil (2.6.1)

pytz (2018.3)

pyzmq (17.0.0)

qtconsole (4.3.1)

scandir (1.7)

scipy (0.13.0b1)

Send2Trash (1.5.0)

setuptools (18.5)

simplegeneric (0.8.1)

singledispatch (3.4.0.3)

six (1.11.0)

subprocess32 (3.2.7)

sympy (1.1.1)

terminado (0.8.1)

testpath (0.3.1)

tornado (4.5.3)

traitlets (4.3.2)

virtualenv (15.1.0)

wcwidth (0.1.7)

webencodings (0.5.1)

widgetsnbextension (3.1.4)

xattr (0.6.4)

zope.interface (4.1.1)

 

实行的下令

python3 -m pip install --user --upgrade matplotlib

 

 

 

 

方法二 Macports

Python 2.7

sudo port install py27-pipsudo pip-2.7 install matplotlib

 

Python 3.6:

sudo port install py36-pipsudo pip-3.6 install matplotlib

 

 

 

 

 2.5 安装包——scipy(pip)

python3 -m pip install scipy import scipy 

 

测验一下

import scipy 

 

 

 

2.6 安装pandas

1.
Anaconda:安装pandas、Python和SciPy最简单易行的形式是用Anaconda。Anaconda是关于Python数据深入分析和科学总计的分发包。

  1. Miniconda
    运用Anaconda会安装一百多少个依据包,固然想灵活决定装置的信赖包或带宽有限,使用Miniconda是个科学的取舍。
    Conda是个包管理器,Anaconda正是创造在它的功底上。Conda不只跨平台还与语言非亲非故,与pip和virtualenv相结合的效率相似。
    Miniconda允许先成立包括Python的安装包,然后用conda安装任何的依赖包。

 

  1. Pypi
    pandas能够因此pip安装,但要安装相关的信赖包。
    [plain] view plain copy
    pip install pandas

 

  1. 包管理器
    可以用linux的包管理器实行安装,如
    [plain] view plain copy
    sudo apt-get install python-pandas 
    zypper in python-pandas

 

  1. 源码安装
    从源码安装需求安装新型的Cython,可用easy-install -U
    cython安装。源码位于

[plain] view plain copy
git clone git://github.com/pydata/pandas.git 
cd pandas 
python setup.py install

 

 

 

2.7 安装TensorFlow(pip) 

#python2版本
pip install tensorflow

 

#python3版本
pip3 install tensorflow

 

 

设置成功后,假使照旧报错

Traceback (most recent call last):
File “MLCNN.py”, line 10, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named ‘tensorflow’

 

 

 

杀鸡取蛋方案1——卸载重装tensorflow(未缓慢解决)

(pip重装**测量检验无效果)**

$ pip uninstall tensorflow
$ pip3 uninstall tensorflow 

www.yabovip4.com 2

 

 

   -csdn/Python与TensorFlow安装境遇难题求助

   -csdn/tensorflow在win上的设置常见错误及正确安装步骤(富含anaconda
spyder)/报错集结

 

 

焚薮而田方案2——用Anaconda来张开激活使用(未缓和)

首先安装Anaconda,安装成功后,创设几个conda情况

 

conda create -n tensorflow pip python = 2.7
conda create -n tensorflow pip python = 3.6
#或python = 3.3等

 

激活境遇

 

source activate tensorflow
# (targetDirectory)$   Your prompt should change

 

在情形中装置Tensorflow

 

pip install --ignore-installed --upgrade \  https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py2-none-any.whl

#TensorFlow for Python 2.7的纯CPU版本

 

pip install --ignore-installed --upgrade \  https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.6.0-py3-none-any.whl

#Python 3.4,3.5或3.6

 

 

参考:

   -tensorflow官网

 

 

 

科学的安装格局

⭐️   -csdn/mac/linux
安装tensorflow和安装Anaconda

 

tensorflow扩充学习

   -tensorflownews/tensorflownews/个人网址

 

 

 

参考:

✅   -cnblogs/在
Mac OS X 上安装 TensorFlow

 

 

 

 

参考:

   -Mac下何以设置配备Homebrew

   -Linux/numpy的下载与安装教程——(消除No
module named numpy难题)

   -python和numpy的版本、安装地方

   -安装Numpy

   -Mac/MAC
使用pycharm出现ImportError: No module named numpy 消除措施

   -安装python package到钦赐目录

   -多版本Python共存时pip给钦定版本的python安装package的不二秘技

   -[Mac] Python Numpy Scipy
Matplotlib 快捷安装

⭐️   -mac os x: Python 3
安装(scipy,numpy,matplotlib. . .)

   -ImportError:
No module named matplotlib

   - tensorflow

 

 

2018-03-0809:00:00

2018-03-0821:17:12

 

发表评论

电子邮件地址不会被公开。 必填项已用*标注