[Fixed]-Dyld: Library not loaded: @executable_path/../.Python

1👍

I also use macOS and I never mess with or even deal with the system python. I’ve installed python3 via Homebrew (https://brew.sh) and I always use a virtual environment. I have one in my home directory (my default) and I have one for each project I’m working on.

Your rule of thumb should be to never run ‘pip’ if you aren’t within a virtualenv. Check with $ echo $VIRTUAL_ENV.

To create/recreate the virtual environment in python3 with the currently installed libraries:

  • Get into your project directory and active your virtualenv.
  • (optional) Dump your requirements via pip: $ pip freeze > requirements.txt
  • Nuke your virtual environment directory if you have one: $ rm -rf .venv
  • Deactivate it: $ deactivate
  • Create a new one with python3: $ virtualenv -p python3 .venv
  • Activate it: $ source .venv/bin/activate
  • (optional) Install your requirements: $ pip install -r requirements.txt
  • Profit.

You can skip the steps for writing and reading the requirements.txt if you just want to create a new virtual environment and then install only the modules you want/need later.

0👍

firstly, to reduce your confusion n which python you are using you could try the following 2 commands in Linux or mac where bash shell is installed:

$ which python
or
$ which python3

in my case, it outputs the python paths I am using with pyenv [with fish shell] [$ is a shell sign]

enter image description here

👤auvipy

Leave a comment