简体   繁体   中英

zsh: abort python error when I try to run the app in venv

I setup Python 3.6 using pyenv so I could manage multiple Python versions (eg 3.7 and 3.8) in the future. I didn't use Homebrew to install Python since it changes the system version. It's my first time to use zsh shell since it's the default shell in Catalina OS. Currently, I use 3.6.8 version for my existing project.

So here's my current setup:

% pyenv versions

result:

  system
* 3.6.8 (set by /Users/macbook/.python-version)
  3.7.3

% python -V results to Python 3.6.8

% which python results to /Users/macbook/.pyenv/shims/python

% echo $PATH results to /Users/macbook/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

The content of my ~/.zshrc is PATH=$(pyenv root)/shims:$PATH

I created a virtual env using % python -m venv venv , installed all the necessary packages, and when I activate it and get the python path,

(venv) % python -V
Python 3.6.8

(venv) % which python
/Users/macbook/python-project/venv/bin/python

(venv) % echo $PATH
/Users/macbook/python-project/venv/bin:/Users/macbook/.pyenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Finally, when I try to run the app, I always get zsh: abort error:

(venv) % python app.py
zsh: abort      python app.py

(venv) % export FLASK_APP=app.py
(venv) % flask run
zsh: abort      flask run

I don't know what else is still missing or are there anything wrong with my python path?

Thanks!

After searching through the web, I think this is a common issue with the latest MacOS or Homebrew. This thread fixed the issue.

  1. brew update && brew upgrade && brew install openssl

  2. copy the two files from /usr/local/Cellar/openssl@1.1/1.1.1g to /usr/local/lib/

    cd /usr/local/Cellar/openssl@1.1/1.1.1g/

    sudo cp libssl.1.1.1.dylib libcrypto.1.1.1.dylib /usr/local/lib/

  3. add symlink to missing openssl libs

    cd /usr/local/lib

    sudo ln -s libssl.1.1.1.dylib libssl.dylib

    sudo ln -s libcrypto.1.1.1.dylib libcrypto.dylib

For me, the below worked:

Python 3.6.9 MacOs Catalina 10.15.7

cd /usr/local/Cellar/openssl@1.1/1.1.1h/
cp lib/libssl.1.1.dylib lib/libcrypto.1.1.dylib /usr/local/lib
cd /usr/local/lib
sudo ln -s libssl.1.1.dylib libssl.dylib
sudo ln -s libcrypto.1.1.dylib libcrypto.dylib

Thanks to the answer by Zhanrah

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM