I decided to change the name of my Flask project folder from microblog to finalproject. I am using Python 3.4.2 on a Mac.

Here's the hierarchy of finalproject:

Vivians-MacBook-Pro:finalproject vivianli$ ls
__pycache__ app.db      db_create.py    db_migrate.py   db_upgrade.py   run.py
app     config.py   db_downgrade.py db_repository   flask       tmp

Since then (and I should have thought this through more carefully before I did this), the path "flask/bin/python" no longer works. For example,

Vivians-MacBook-Pro:finalproject vivianli$ ./db_migrate.py
-bash: ./db_migrate.py: flask/bin/python: bad interpreter: No such file or directory

db_migrate.py is a migrating script that I've granted permission to. However when I use flask/bin/python3, it works.

My question is why flask/bin/python doesn't work anymore, why flask/bin/python3 does after changing my overall project name, and if there are any other settings I should be concerned about.

3

There are 3 best solutions below

0
On

You are working with a virtual environnement located in the ./flask folder, so have a look at the flask/bin folder and pick a python interpreter.

First make sure you have activated the virtual environment by launching

$ source ./flask/bin/activate

Also check for your interpreter in ./flask/bin/python

$ ls -lsa ./flask/bin/

You should find here python3.4 or something similar and python pointing on it, about like this :

 0 lrwxrwxrwx 1 fx fx     9 31 mai   14:29 python -> python3.4
 0 lrwxrwxrwx 1 fx fx     9 31 mai   14:29 python3 -> python3.4
12 -rwxr-xr-x 1 fx fx 10440 31 mai   14:29 python3.4

If not, you might need to make a symbolic link from python3 to python in your virtual environment to avoid finding the same problem in other scripts of the project.

$ cd ./flask/bin
$ ln -s ./python3 ./python

This might fix your problem.

0
On

It seems that you got killed a link to python executable. Seems you are using virtualenv: try to recreate it like this:

rm -rf flask
virtualenv --clear flask

Or, if you don't want to do that, you can remake link to python executable

cd ./flask/bin
rm -rf python
ln -s <location, where the python is installed>/python ./
0
On

Looks like flask was not finding python in the venv. In the flask/bin folder deleted both python, python3 folders

Recreated the link to python3

$ ln -s <{python Installed Path}>/python3 ./
$ ln -s ./python3 ./python

Thenter code hereis worked for me.