折腾:
【未解决】Mac中给Python 3.7中安装python库numpy和pandas
期间,去mac中,用pyenv管理python版本,安装python 3.7
感觉是:
mac python pyenv
➜ ~ brew install pyenv Updating Homebrew...
太慢,中断了。
试试直接:
brew upgrade pyenv
结果也需要Updating Homebrew…
➜ ~ brew upgrade pyenv Updating Homebrew...
那就等吧
➜ ~ brew upgrade pyenv Updating Homebrew... Warning: pyenv 1.2.11 already installed
已经安装了。
➜ ~ pyenv version system (set by /Users/crifan/.pyenv/version) ➜ ~ pyenv versions * system (set by /Users/crifan/.pyenv/version) 3.5.2 3.6.6
是貌似可以用了。
但是找不到我们另外的python 3.7
算了,换这个3.6.6:
➜ ~ pyenv versions * system (set by /Users/crifan/.pyenv/version) 3.5.2 3.6.6 ➜ ~ pyenv global 3.6.6 ➜ ~ which python /Users/crifan/.pyenv/shims/python ➜ ~ python --version Python 3.6.6
不过,也最好还是换更加新的3.7的
pyenv install --list
有很多版本:
➜ ~ pyenv install --list Available versions: 2.1.3 ... 3.5.7 3.6.0 3.6-dev 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7-dev 3.7.1 3.7.2 3.7.3 3.8-dev
去安装3.7的最新版 3.7.3
pyenv install 3.7.3
结果:
【已解决】Mac中如何给pyenv install加速
➜ cache pyenv install -v 3.7.3 python-build: use openssl from homebrew python-build: use readline from homebrew /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/python-build.20200227213416.57009 ~/.pyenv/cache /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/python-build.20200227213416.57009/Python-3.7.3 /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/python-build.20200227213416.57009 ~/.pyenv/cache Installing Python-3.7.3... python-build: use readline from homebrew checking build system type... x86_64-apple-darwin19.2.0 checking host system type... x86_64-apple-darwin19.2.0 checking for python3.7... python3.7 checking for --enable-universalsdk... no checking for --with-universal-archs... no checking MACHDEP... checking for --without-gcc... no checking for --with-icc... no checking for gcc... clang checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether clang accepts -g... yes checking for clang option to accept ISO C89... none needed checking how to run the C preprocessor... clang -E checking for grep that handles long lines and -e... /usr/bin/grep checking for a sed that does not truncate output... /usr/bin/sed checking for --with-cxx-main=<compiler>... no checking for clang++... no configure: By default, distutils will build C++ extension modules with "clang++". If this is not intended, then set CXX on the configure command line. checking for the platform triplet based on compiler characteristics... darwin checking for -Wl,--no-as-needed... no checking for egrep... /usr/bin/grep -E checking for ANSI C header files... yes ... on... no checking for openssl/ssl.h in /usr/local/opt/openssl... yes checking whether compiling and linking against OpenSSL works... yes checking for X509_VERIFY_PARAM_set1_host in libssl... yes checking for --with-ssl-default-suites... python configure: creating ./config.status config.status: creating Makefile.pre config.status: creating Misc/python.pc config.status: creating Misc/python-config.sh config.status: creating Modules/ld_so_aix config.status: creating pyconfig.h creating Modules/Setup creating Modules/Setup.local creating Makefile If you want a release build with all stable optimizations active (PGO, etc), please run ./configure --enable-optimizations clang -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c clang -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -DPy_BUILD_CORE -o Parser/acceler.o Parser/acceler.c clang -c -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Wstrict-prototypes -Werror=implicit-function-declaration -I. -I./Include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -I/usr/local/opt/readline/include -I/usr/local/opt/readline/include -I/Users/crifan/.pyenv/versions/3.7.3/include -I/usr/local/opt/zlib/include -DPy_BUILD_CORE -o Parser/grammar1.o Parser/grammar1.c ... ld: warning: could not create compact unwind for _ffi_call_unix64: does not use RBP or RSP based frame ... copying build/lib.macosx-10.15-x86_64-3.7/_lsprof.cpython-37m-darwin.so -> /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload copying build/lib.macosx-10.15-x86_64-3.7/resource.cpython-37m-darwin.so -> /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload copying build/lib.macosx-10.15-x86_64-3.7/parser.cpython-37m-darwin.so -> /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload copying build/lib.macosx-10.15-x86_64-3.7/_random.cpython-37m-darwin.so -> /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload changing mode of /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/_sysconfigdata_m_darwin_darwin.py to 644 changing mode of /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/_sha1.cpython-37m-darwin.so to 755 changing mode of /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/_testbuffer.cpython-37m-darwin.so to 755 ... changing mode of /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/ to 755 changing mode of /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/__pycache__ to 755 running install_scripts copying build/scripts-3.7/pyvenv-3.7 -> /Users/crifan/.pyenv/versions/3.7.3/bin copying build/scripts-3.7/pydoc3.7 -> /Users/crifan/.pyenv/versions/3.7.3/bin copying build/scripts-3.7/idle3.7 -> /Users/crifan/.pyenv/versions/3.7.3/bin copying build/scripts-3.7/2to3-3.7 -> /Users/crifan/.pyenv/versions/3.7.3/bin changing mode of /Users/crifan/.pyenv/versions/3.7.3/bin/pyvenv-3.7 to 755 changing mode of /Users/crifan/.pyenv/versions/3.7.3/bin/pydoc3.7 to 755 changing mode of /Users/crifan/.pyenv/versions/3.7.3/bin/idle3.7 to 755 changing mode of /Users/crifan/.pyenv/versions/3.7.3/bin/2to3-3.7 to 755 rm /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/_sysconfigdata_m_darwin_darwin.py rm -r /Users/crifan/.pyenv/versions/3.7.3/lib/python3.7/lib-dynload/__pycache__ Creating directory /Users/crifan/.pyenv/versions/3.7.3/share/man Creating directory /Users/crifan/.pyenv/versions/3.7.3/share/man/man1 /usr/bin/install -c -m 644 ./Misc/python.man \ /Users/crifan/.pyenv/versions/3.7.3/share/man/man1/python3.7.1 if test ! -d /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig; then \ echo "Creating directory /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig"; \ /usr/bin/install -c -d -m 755 /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig; \ fi if test -f /Users/crifan/.pyenv/versions/3.7.3/bin/python3 -o -h /Users/crifan/.pyenv/versions/3.7.3/bin/python3; \ then rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/python3; \ else true; \ fi (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s python3.7 python3) if test "3.7" != "3.7m"; then \ rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/python3.7-config; \ (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s python3.7m-config python3.7-config); \ rm -f /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig/python-3.7m.pc; \ (cd /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig; ln -s python-3.7.pc python-3.7m.pc); \ fi rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/python3-config (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s python3.7-config python3-config) rm -f /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig/python3.pc (cd /Users/crifan/.pyenv/versions/3.7.3/lib/pkgconfig; ln -s python-3.7.pc python3.pc) rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/idle3 (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s idle3.7 idle3) rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/pydoc3 (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s pydoc3.7 pydoc3) rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/2to3 (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s 2to3-3.7 2to3) rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/pyvenv (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s pyvenv-3.7 pyvenv) if test "x" != "x" ; then \ rm -f /Users/crifan/.pyenv/versions/3.7.3/bin/python3-32; \ (cd /Users/crifan/.pyenv/versions/3.7.3/bin; ln -s python3.7-32 python3-32) \ fi rm -f /Users/crifan/.pyenv/versions/3.7.3/share/man/man1/python3.1 (cd /Users/crifan/.pyenv/versions/3.7.3/share/man/man1; ln -s python3.7.1 python3.1) if test "xupgrade" != "xno" ; then \ case upgrade in \ upgrade) ensurepip="--upgrade" ;; \ install|*) ensurepip="" ;; \ esac; \ ./python.exe -E -m ensurepip \ $ensurepip --root=/ ; \ fi Looking in links: /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/tmptocrfmfl Collecting setuptools Collecting pip Installing collected packages: setuptools, pip Successfully installed pip-19.0.3 setuptools-40.8.0 WARNING: The Python sqlite3 extension was not compiled. Missing the SQLite3 lib? /var/folders/46/2hjxz38n22n3ypp_5f6_p__00000gn/T/python-build.20200227213416.57009 ~/.pyenv/cache ~/.pyenv/cache Installed Python-3.7.3 to /Users/crifan/.pyenv/versions/3.7.3
继续等待漫长的编译过程
终于完成了。
➜ cache pyenv versions system 3.5.2 * 3.6.6 (set by /Users/crifan/.pyenv/version) 3.7.3 ➜ cache pyenv global 3.7.3 ➜ cache which python /Users/crifan/.pyenv/shims/python ➜ cache python --version Python 3.7.3 ➜ cache pyenv which python /Users/crifan/.pyenv/versions/3.7.3/bin/python
设置好了。
【总结】
此处,安装python 3.7,且设置为系统python的步骤是:
1.下载和安装
pyenv install -v 3.7.3
注:如果速度慢,则自己下载:
放到cache中 ~/.pyenv/cache
2.设置
pyenv global 3.7.3
即可。