Yosemite install OpenCV3

来源:互联网 发布:comsol软件下载 编辑:程序博客网 时间:2024/06/11 05:05

先声明一下,我参考的安装文章在 [这里] 。(http://www.pyimagesearch.com/2016/12/05/macos-install-opencv-3-and-python-3-5/)
我的环境与教程的环境有一些差别,在这之前我安装了Anaconda和Pycharm,所以在安装的时候曾担心会遇到一些冲突的问题,后来想了一下,先不管他了,试试再说。现在我记录一下安装的过程,是边安装边记录的,我也不知道能不能安装成功。

由于之前系统已经安装过homebrew了,所以就跳过安装的步骤,Step #2: Install Homebrew,执行了一下

brew update
 ~/ brew updateUpdated 2 taps (homebrew/core, homebrew/science).==> New Formulaeakamai                      glpk                        metis                       redis@3.2                   veclibfortarpack                      goose                       octave                      scalapackbash-snippets               homebrew/science/clips      openblas                    sccachebento4                      homebrew/science/flexbar    qhull                       suite-sparseghc@8.0                     maven@3.0                   qrupdate                    transfig==> Updated Formulaeafl-fuzz                           get-flash-videos                   libqalculate                       pyenv-virtualenvafsctool                           getmail                            librdkafka                         pyinvokeagda                               ghc                                librsvg                            pyqtallure                             git-fresh                          libtiff ✔                          qscintilla2amazon-ecs-cli                     gitlab-ci-multi-runner             libtorrent-rasterbar               rcloneammonite-repl                      gjs                                linkerd                            reattach-to-user-namespaceangular-cli                        gnatsd                             log4cpp                            recoverjpegapache-arrow                       gnome-recipes                      logstash                           redisapp-engine-go-64                   gnu-chess                          lxc                                rethinkdbarangodb                           gnupg                              macvim                             rocksdbartifactory                        gnupg@1.4                          makensis                           rom-toolsascii                              gofabric8                          mame                               rtagsassimp                             google-benchmark                   mariadb                            ruby-buildaws-sdk-cpp                        gradle                             memcached                          rustbacula-fd                          grakn                              menhir                             sbtbazel                              groonga                            meson                              scalabinutils                           gsoap                              metabase                           scalaenvbmake                              gtk+3                              metricbeat                         scalariformbtfs                               harfbuzz                           miller                             scwcabal-install                      haskell-stack                      mingw-w64                          shadowsocks-libevcaddy                              haste-client                       mkvtoolnix                         sipcargo-completion                   hdf5 ✔                             mobile-shell                       sjkcatimg                             heroku                             monax                              skinnychakra                             highlight                          mpc                                snakemakecheckstyle                         homebrew/science/alembic           mpd                                snap-telemetrychromedriver                       homebrew/science/ampl-mp           mpdas                              softhsmclosure-stylesheets                homebrew/science/bedops            mpg123                             sslyzecmake                              homebrew/science/ceres-solver      mpv                                stellacockroach                          homebrew/science/cgns              mspdebug                           supervisorcodec2                             homebrew/science/cmor              mypy                               suricataconan                              homebrew/science/dynare            mysql                              swiftplateconsul                             homebrew/science/gmsh              mysql-cluster                      syncthingconvmv                             homebrew/science/htslib            mysql-connector-c                  sysdigconvox                             homebrew/science/ipopt             mysql-sandbox                      t1utilscorectl                            homebrew/science/libbigwig         mysql@5.5                          talloccromwell                           homebrew/science/littler           mysql@5.6                          tarsnap-guicrowdin                            homebrew/science/mumps             nano                               tcl-tkcryptol                            homebrew/science/nextflow          ncmpc                              tcpdumpcython                             homebrew/science/ome-common        ncmpcpp                            tee-clcdbt                                homebrew/science/ome-files         netpbm                             telegrafdbus                               homebrew/science/ome-xml           nnn                                teleportdcos-cli                           homebrew/science/root6             node                               terragruntdependency-check                   homebrew/science/vcftools          node-build                         tfenvdhall-json                         htmldoc                            node@4                             tikadiff-so-fancy                      httpflow                           node@6                             tippecanoediffoscope                         hydra                              nomad                              trafficserverdigdag                             hyperscan                          notmuch                            twopingdmd                                imagemagick                        nsd                                typescriptdocker-compose                     imagemagick@6                      nspr                               unrardocker-compose-completion          influxdb                           nuxeo                              urhdub                                influxdb@0.8                       ola                                v8@3.15duck                               ircii                              openrtsp                           vimelasticsearch                      jags                               opensc                             vimpcelasticsearch@2.4                  jboss-forge                        openvdb                            vipselixir                             jenkins                            orc                                voldemortemscripten                         jenkins-lts                        orientdb                           vowpal-wabbitencfs                              jfrog-cli-go                       osc                                webdisetcd                               jhipster                           osm2pgsql                          webpacketsh                               jmxtrans                           osquery                            whoisevince                             kibana                             osrm-backend                       wineexploitdb                          kobalt                             oysttyer                           wiredtigerfabio                              kompose                            packetbeat                         wireguard-toolsfibjs                              kops                               paket                              wiresharkfilebeat                           kubernetes-cli                     parallel                           woboq_codebrowserflake8                             kubernetes-helm                    passenger                          wpscanflow                               languagetool                       pgbadger                           xapianfluent-bit                         launch4j                           pgcli                              xsvfolly                              lean-cli                           pioneer                            yarnformat-udf                         libfreenect                        ponyc                              yle-dlfstar                              libgcrypt                          pre-commit                         you-getfzf                                libhttpseverywhere                 presto                             youtube-dlgdk-pixbuf                         libmpdclient                       protobuf-swift                     zabbixgearman                            libphonenumber                     psqlodbc                           zsh-completionsgeos                               libpst                             pulseaudio ~/ vi ~/.bash_profile

教程接下来是添加brew的安装路径,以便的命令行输入brew后系统能够找到它,同样,我之前已经安装过了,所以就查看了一下安装路径。已经添加好了。

 ~/ which brew/usr/local/bin/brew ~/ echo $PATH/Users/zz/anaconda/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin ~/

接下来教程是安装Python3,这个我之前也安装好了,是装Anaconda的时候装的,并且系统上有好几个Python,在/usr/bin目录下的是osx系统自带的,且为python2.x的版本,我的目标是装python3.x和opencv,所以那个肯定就不能用了。

 ~/ which python3/Users/zz/anaconda/bin/python3 ~/ ~/ which python/Users/zz/anaconda/bin/python ~/ ~/ ls /usr/bin/pyth*/usr/bin/python           /usr/bin/python2.6        /usr/bin/python2.7        /usr/bin/pythonw          /usr/bin/pythonw2.7/usr/bin/python-config    /usr/bin/python2.6-config /usr/bin/python2.7-config /usr/bin/pythonw2.6 ~/

在这一步,教程使用了brew 安装了python3,装在了/usr/local/bin/python3里面了。而具体我的本机的情况,python3的安装路径则为:

 ~/ which python3/Users/zz/anaconda/bin/python3 ~/

所以在后面配置的时候需要把教程中有关/usr/local/bin/python3的路径改成我的 /user/zz/anaconda/bin/python3 ,这是目前能够想到的。

继续。Step #4: Install Python virtual environments and NumPy 接下来是安装 virtual environments.

 pip install virtualenv virtualenvwrapper

这个东西我的系统里确实没有,所以该实际的安装了。

 ~/ pip install virtualenv virtualenvwrapperCollecting virtualenv  Downloading virtualenv-15.1.0-py2.py3-none-any.whl (1.8MB)    100% |████████████████████████████████| 1.8MB 132kB/sCollecting virtualenvwrapper  Downloading virtualenvwrapper-4.7.2.tar.gz (90kB)    100% |████████████████████████████████| 92kB 73kB/sCollecting virtualenv-clone (from virtualenvwrapper)  Downloading virtualenv-clone-0.2.6.tar.gzCollecting stevedore (from virtualenvwrapper)  Downloading stevedore-1.25.0-py2.py3-none-any.whlCollecting pbr!=2.1.0,>=2.0.0 (from stevedore->virtualenvwrapper)  Downloading pbr-3.1.1-py2.py3-none-any.whl (99kB)    100% |████████████████████████████████| 102kB 55kB/sRequirement already satisfied: six>=1.9.0 in ./anaconda/lib/python3.6/site-packages (from stevedore->virtualenvwrapper)Building wheels for collected packages: virtualenvwrapper, virtualenv-clone  Running setup.py bdist_wheel for virtualenvwrapper ... done  Stored in directory: /Users/zz/Library/Caches/pip/wheels/3e/7e/eb/31f2187dde819aa4f67ade0ac8401da47257f44c213f153ca2  Running setup.py bdist_wheel for virtualenv-clone ... done  Stored in directory: /Users/zz/Library/Caches/pip/wheels/24/51/ef/93120d304d240b4b6c2066454250a1626e04f73d34417b956dSuccessfully built virtualenvwrapper virtualenv-cloneInstalling collected packages: virtualenv, virtualenv-clone, pbr, stevedore, virtualenvwrapperSuccessfully installed pbr-3.1.1 stevedore-1.25.0 virtualenv-15.1.0 virtualenv-clone-0.2.6 virtualenvwrapper-4.7.2 ~/ ls /usr/local/bin/2to3                  exrmakepreview        h5format_convert      mdb_copy              ppm2tiff              tiff2pdf2to3-3.6              exrmaketiled          h5import              mdb_dump              pprof                 tiff2psVBoxAutostart         exrmultipart          h5jam                 mdb_load              pydoc3                tiff2rgbaVBoxBalloonCtrl       exrmultiview          h5ls                  mdb_stat              pydoc3.6              tiffcmpVBoxBugReport         exrstdattr            h5mkgrp               ocs                   python3               tiffcpVBoxDTrace            f2py                  h5perf_serial         opencv_annotation     python3-32            tiffcropVBoxHeadless          fax2ps                h5redeploy            opencv_createsamples  python3-config        tiffditherVBoxManage            fax2tiff              h5repack              opencv_haartraining   python3.6             tiffdumpVBoxVRDP              gflags_completions.sh h5repart              opencv_performance    python3.6-32          tiffinfoVirtualBox            gif2h5                h5stat                opencv_traincascade   python3.6-config      tiffmedianbrew                  h52gif                h5unjam               opencv_version        python3.6m            tiffsetcjpeg                 h5c++                 h5watch               opencv_visualisation  python3.6m-config     tiffsplitcscope                h5cc                  idle3                 pal2rgb               pyvenv                vbox-imgctags                 h5clear               idle3.6               pip3                  pyvenv-3.6            vboxwebsrvdjpeg                 h5copy                jpegtran              pip3.6                raw2tiff              wrjpgcomeasy_install-3.6      h5debug               leveldbutil           png-fix-itxt          rdjpgcomexrenvmap             h5diff                libpng-config         pngfix                sandbox-podexrheader             h5dump                libpng16-config       pod                   tiff2bw ~/ virtualenv_prompt_info

还算顺利,直接就安装完了。
然后接下来,教程说

# Virtualenv/VirtualenvWrappersource /usr/local/bin/virtualenvwrapper.sh

但是我看了一下,在我本地/usr/local/bin目录下根本就没有virtualenvwrapper.sh这个文件。慌了2秒钟,企图使用直接拼写看看系统能不能自动补全,结果只出来一个virtualenv_prompt_ifo,没有想要的virtualenvwrapper.sh,用find查找出来一堆Permission denied。又进了几个目录看了一下,也还是没有。

 ~/ virtualenv_prompt_info ~/ find / -name virtualenvwrapper.shfind: /.DocumentRevisions-V100: Permission deniedfind: /.fseventsd: Permission deniedfind: /.Spotlight-V100: Permission deniedfind: /.Trashes: Permission deniedfind: /dev/fd/3: Not a directoryfind: /dev/fd/4: Not a directoryfind: /Library/Application Support/Apple/ParentalControls/Users: Permission deniedfind: /Library/Application Support/ApplePushService: Permission deniedfind: /Library/Application Support/com.apple.TCC: Permission deniedfind: /Library/Caches/com.apple.iconservices.store: Permission deniedfind: /Library/Caches/com.apple.Spotlight/schema.501.plist: Permission deniedfind: /Library/Caches/com.apple.Spotlight/schema.89.plist: Permission deniedfind: /Library/Caches/com.apple.Spotlight: Permission deniedfind: /private/etc/cups/certs: Permission deniedfind: /private/var/agentx: Permission deniedfind: /private/var/at/tabs: Permission deniedfind: /private/var/at/tmp: Permission deniedfind: /private/var/audit: Permission deniedfind: /private/var/backups: Permission deniedfind: /private/var/db/caches/opendirectory: Permission deniedfind: /private/var/db/ConfigurationProfiles/Setup: Permission deniedfind: /private/var/db/ConfigurationProfiles/Store: Permission deniedfind: /private/var/db/dhcpclient: Permission deniedfind: /private/var/db/dslocal/nodes/Default: Permission deniedfind: /private/var/db/geod: Permission deniedfind: /private/var/db/locationd: Permission deniedfind: /private/var/db/lockdown: Permission deniedfind: /private/var/db/nsurlsessiond: Permission deniedfind: /private/var/db/securityagent: Permission deniedfind: /private/var/db/Spotlight: Permission deniedfind: /private/var/db/sudo: Permission deniedfind: /private/var/db/TokenCache: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.revisiond.temp: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/0/com.apple.Spotlight: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000000000000/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n000003000000r/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n000003800000t/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n000006w00001q/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n000006w00001q/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000084000021/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n0000084000021/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000b400002s/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000b400002s/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000bh00002w/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000bh00002w/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000c4000031/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000c4000031/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s0000068/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s0000068/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s800006_/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000s800006_/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000sm00006d/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000t800006k/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000th00006m/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000th00006m/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000tm00006n/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000vr00006y/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000vr00006y/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000xc00007b/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000xc00007b/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y000007h/C: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y000007h/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y400007j/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000y800007k/T: Permission deniedfind: /private/var/folders/zz/zyxvpxvq6csfxvn_n00000yc00007l/T: Permission deniedfind: /private/var/jabberd: Permission deniedfind: /private/var/lib/postfix: Permission deniedfind: /private/var/log/com.apple.revisiond: Permission deniedfind: /private/var/log/watchdogd/log: Permission deniedfind: /private/var/log/watchdogd: Permission deniedfind: /private/var/root: Permission deniedfind: /private/var/run/mds: Permission deniedfind: /private/var/spool/cups: Permission deniedfind: /private/var/spool/fax: Permission deniedfind: /private/var/spool/mqueue: Permission deniedfind: /private/var/spool/postfix/active: Permission deniedfind: /private/var/spool/postfix/bounce: Permission deniedfind: /private/var/spool/postfix/corrupt: Permission deniedfind: /private/var/spool/postfix/defer: Permission deniedfind: /private/var/spool/postfix/deferred: Permission deniedfind: /private/var/spool/postfix/flush: Permission deniedfind: /private/var/spool/postfix/hold: Permission deniedfind: /private/var/spool/postfix/incoming: Permission deniedfind: /private/var/spool/postfix/maildrop: Permission deniedfind: /private/var/spool/postfix/private: Permission deniedfind: /private/var/spool/postfix/public: Permission deniedfind: /private/var/spool/postfix/saved: Permission deniedfind: /private/var/spool/postfix/trace: Permission deniedfind: /System/Library/Caches/com.apple.coresymbolicationd: Permission deniedfind: /System/Library/DirectoryServices/DefaultLocalDB/Default: Permission deniedfind: /System/Library/User Template: Permission denied/Users/zz/anaconda/bin/virtualenvwrapper.shfind: /usr/sbin/authserver: Permission deniedfind: /Volumes/PyCharm/.Trashes: Permission denied ~/ ls /Library/Frameworks/Python.framework/Versions/3.6/bin/2to3              idle3             pip3.6            python3           python3.6         python3.6m        pyvenv-3.62to3-3.6          idle3.6           pydoc3            python3-32        python3.6-32      python3.6m-configeasy_install-3.6  pip3              pydoc3.6          python3-config    python3.6-config  pyvenv ~/ ls /Library/Frameworks/Python.framework/Versions/3.6/bin/ -alls: -al: No such file or directory/Library/Frameworks/Python.framework/Versions/3.6/bin/:2to3              idle3             pip3.6            python3           python3.6         python3.6m        pyvenv-3.62to3-3.6          idle3.6           pydoc3            python3-32        python3.6-32      python3.6m-configeasy_install-3.6  pip3              pydoc3.6          python3-config    python3.6-config  pyvenv ~/ ls -al /Library/Frameworks/Python.framework/Versions/3.6/bin/total 272drwxrwxr-x  21 root  admin    714 Feb  9 08:09 .drwxrwxr-x  10 root  admin    340 Feb  9 08:09 ..lrwxr-xr-x   1 root  admin      8 Feb  9 08:09 2to3 -> 2to3-3.6-rwxrwxr-x   1 root  admin    140 Dec 23  2016 2to3-3.6-rwxrwxr-x   1 root  admin    281 Feb  9 08:09 easy_install-3.6lrwxr-xr-x   1 root  admin      7 Feb  9 08:09 idle3 -> idle3.6-rwxrwxr-x   1 root  admin    138 Dec 23  2016 idle3.6-rwxrwxr-x   1 root  admin    253 Feb  9 08:09 pip3-rwxrwxr-x   1 root  admin    253 Feb  9 08:09 pip3.6lrwxr-xr-x   1 root  admin      8 Feb  9 08:09 pydoc3 -> pydoc3.6-rwxrwxr-x   1 root  admin    123 Dec 23  2016 pydoc3.6lrwxr-xr-x   1 root  admin      9 Feb  9 08:09 python3 -> python3.6lrwxr-xr-x   1 root  admin     12 Feb  9 08:09 python3-32 -> python3.6-32lrwxr-xr-x   1 root  admin     16 Feb  9 08:09 python3-config -> python3.6-config-rwxrwxr-x   2 root  admin  25920 Dec 23  2016 python3.6-rwxrwxr-x   1 root  admin  13568 Dec 23  2016 python3.6-32lrwxr-xr-x   1 root  admin     17 Feb  9 08:09 python3.6-config -> python3.6m-config-rwxrwxr-x   2 root  admin  25920 Dec 23  2016 python3.6m-rwxrwxr-x   1 root  admin   2081 Dec 23  2016 python3.6m-configlrwxr-xr-x   1 root  admin     10 Feb  9 08:09 pyvenv -> pyvenv-3.6-rwxrwxr-x   1 root  admin    480 Dec 23  2016 pyvenv-3.6 ~/ ls /usr/local/bin2to3                  exrmakepreview        h5format_convert      mdb_copy              ppm2tiff              tiff2pdf2to3-3.6              exrmaketiled          h5import              mdb_dump              pprof                 tiff2psVBoxAutostart         exrmultipart          h5jam                 mdb_load              pydoc3                tiff2rgbaVBoxBalloonCtrl       exrmultiview          h5ls                  mdb_stat              pydoc3.6              tiffcmpVBoxBugReport         exrstdattr            h5mkgrp               ocs                   python3               tiffcpVBoxDTrace            f2py                  h5perf_serial         opencv_annotation     python3-32            tiffcropVBoxHeadless          fax2ps                h5redeploy            opencv_createsamples  python3-config        tiffditherVBoxManage            fax2tiff              h5repack              opencv_haartraining   python3.6             tiffdumpVBoxVRDP              gflags_completions.sh h5repart              opencv_performance    python3.6-32          tiffinfoVirtualBox            gif2h5                h5stat                opencv_traincascade   python3.6-config      tiffmedianbrew                  h52gif                h5unjam               opencv_version        python3.6m            tiffsetcjpeg                 h5c++                 h5watch               opencv_visualisation  python3.6m-config     tiffsplitcscope                h5cc                  idle3                 pal2rgb               pyvenv                vbox-imgctags                 h5clear               idle3.6               pip3                  pyvenv-3.6            vboxwebsrvdjpeg                 h5copy                jpegtran              pip3.6                raw2tiff              wrjpgcomeasy_install-3.6      h5debug               leveldbutil           png-fix-itxt          rdjpgcomexrenvmap             h5diff                libpng-config         pngfix                sandbox-podexrheader             h5dump                libpng16-config       pod                   tiff2bw

这时想起来,还有个which,赶紧试试。终于找到了,原来它就在/user/zz/anaconda/bin/里面,看来都安装到anaconda的目录了。按照教程也把它的路径添加到~/.bash_profile,以便在以后打开终端的时候自动加载它。同时,先用source更新一下本终端。

 ~/ which virtualenvwrapper.sh/Users/zz/anaconda/bin/virtualenvwrapper.sh ~/ vi ~/.bash_profile ~/ source ~/.bash_profilevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/premkprojectvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/postmkprojectvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/initializevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/premkvirtualenvvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/postmkvirtualenvvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/prermvirtualenvvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/postrmvirtualenvvirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/predeactivatevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/postdeactivatevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/preactivatevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/postactivatevirtualenvwrapper.user_scripts creating /Users/zz/.virtualenvs/get_env_details ~/ ls .virtualenvsget_env_details  postactivate     postmkproject    postrmvirtualenv predeactivate    premkvirtualenvinitialize       postdeactivate   postmkvirtualenv preactivate      premkproject     prermvirtualenv ~/ ls -al .virtualenvstotal 96drwxr-xr-x  14 zz  staff   476 Jul 29 16:53 .drwxr-xr-x+ 47 zz  staff  1598 Jul 29 16:53 ..-rwxr-xr-x   1 zz  staff   134 Jul 29 16:53 get_env_details-rw-r--r--   1 zz  staff    95 Jul 29 16:53 initialize-rw-r--r--   1 zz  staff    72 Jul 29 16:53 postactivate-rw-r--r--   1 zz  staff    74 Jul 29 16:53 postdeactivate-rwxr-xr-x   1 zz  staff    65 Jul 29 16:53 postmkproject-rw-r--r--   1 zz  staff    72 Jul 29 16:53 postmkvirtualenv-rwxr-xr-x   1 zz  staff   109 Jul 29 16:53 postrmvirtualenv-rwxr-xr-x   1 zz  staff    98 Jul 29 16:53 preactivate-rw-r--r--   1 zz  staff    75 Jul 29 16:53 predeactivate-rwxr-xr-x   1 zz  staff    90 Jul 29 16:53 premkproject-rwxr-xr-x   1 zz  staff   129 Jul 29 16:53 premkvirtualenv-rwxr-xr-x   1 zz  staff   110 Jul 29 16:53 prermvirtualenv ~/

接着跟着教程走。
Create your Python 3 virtual environment

$ mkvirtualenv cv -p python3

我本地执行结果:

 ~/ $ mkvirtualenv cv -p python3zsh: command not found: $ ~/ mkvirtualenv cv -p python3zsh: command not found: mkvirtualenv ~/ brew install mkvirtualenvUpdating Homebrew...Error: No available formula with the name "mkvirtualenv"==> Searching for a previously deleted formula...Warning: homebrew/core is shallow clone. To get complete history run:  git -C "$(brew --repo homebrew/core)" fetch --unshallowError: No previously deleted formula found.==> Searching for similarly named formulae...Error: No similarly named formulae found.==> Searching taps...Error: No formulae found in taps.

很明显,又一次装B失败。系统没有找到mkvirtualenv,由于想都没想就用brew 尝试安装它,直到提示安装失败才回过味来,是不是它是在刚才安装 virtualenv virtualenvwrapper 时装上的东西,但是为什么提示找不到呢,赶紧又source ~/.bash_profile,终于可以执行了。回想了一下为什么要source一下才行,不是应该系统自动初始化的吗?难道是我这几天没有关机,导致没有初始化console的关系?先不管了。本以为会大功告成,结果出来了错误。

 ~/ source ~/.bash_profile ~/ mkvirtualenv cv -p python3Running virtualenv with interpreter /Users/zz/anaconda/bin/python3Using base prefix '/Users/zz/anaconda'New python executable in /Users/zz/.virtualenvs/cv/bin/python3Also creating executable in /Users/zz/.virtualenvs/cv/bin/pythondyld: Library not loaded: @rpath/libpython3.6m.dylib  Referenced from: /Users/zz/.virtualenvs/cv/bin/python3  Reason: image not foundERROR: The executable /Users/zz/.virtualenvs/cv/bin/python3 is not functioningERROR: It thinks sys.prefix is '/Users/zz/.virtualenvs' (should be '/Users/zz/.virtualenvs/cv')ERROR: virtualenv is not compatible with this system or executable ~/

说实话,直到此时,我才查了一下:

virtualenv 是一个可以在同一计算机中隔离多个python版本的工具。有时,两个不同的项目可能需要不同版本的python,如 python2.6.6 / python3.0 ,但是如果都装到一起,经常会导致问题。所以需要一个工具能够将这两种或几种不同版本的环境隔离开来,需要哪个版本就切换到哪个版本做为默认版本。virtualenv 既是满足这个需求的工具。它能够用于创建独立的Python环境,多个Python相互独立,互不影响,能够:在没有权限的情况下安装新套件不同应用可以使用不同的套件版本套件升级不影响其他应用作者:乾九二链接:http://www.jianshu.com/p/44ab75fbaef2來源:简书著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
原创粉丝点击