[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Help](/c/help/9)

# Python,Function Runtimes must have a valid version

550 views · 1 like · 6 posts


AJiaBoKe (@lijunyi2) · 2024-07-30

My app.py is just a simple Python program, vercel console node version I set to 18x, and then my vercel.json configuration is as follows, when I deploy, prompt picture error. How do I solve it?

![image|690x65](upload://QxFRgHQICQM7r93W4xEjriwyCV.png)

my vercel.json
```json
{
	"version": 2,
    "functions": {
        "app.py": {
            "runtime": "vercel-python@3.9" , // or vercel-python@3.12
            "maxDuration": 30,
            "memory": 1024
        }
    },
    "routes": [
        {
            "src": "/(.*)",
            "dest": "/app.py"
        }
    ]
}

```


Pauline P. Narvas (@pawlean) · 2024-07-30 · ♥ 1

Hi, @lijunyi2!

Welcome to the Vercel Community :smiley: 

I don't see any issues with your `vercel.json` file. Do you have any other configuration files e.g. `requirements.txt`?

Some things I would try:

* Removing the runtime on your `.json` all together. You don't necessarily need to specify the version as by default, new projects will use the latest Python version available on Vercel.

* Specifying the version in a `Pipfile`. From the [relevant documentation](https://vercel.com/docs/functions/runtimes/python#python-version):

```
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
 
[packages]
flask = "*"
 
[requires]
python_version = "3.12"
```

I'll also leave some examples of some Python projects that might be helpful to look at.

https://github.com/vercel/examples/tree/main/python


AJiaBoKe (@lijunyi2) · 2024-07-31

My `requirements.txt` content is as follows:
```
Flask==3.0.3
Flask-Cors==3.0.10
gunicorn==20.1.0
```

my  `app.py` content is as follows:
``` python
from flask import Flask, request, jsonify
from flask_cors import CORS
import poplib
from email.parser import BytesParser
import re
import time

app = Flask(__name__)
CORS(app)


@app.route('/', methods=['POST'])
def home():
    return jsonify({"msg": "test",
                    "data": "test"}), 200
```
The structure of my project is as follows:
![image|690x446](upload://dDqTMGARkt42ohvXnyNtUCWcdDD.png)

So how can I modify my configuration to solve this deployment problem?


AJiaBoKe (@lijunyi2) · 2024-07-31

I solved it myself, thank you.


Pauline P. Narvas (@pawlean) · 2024-07-31

Great to hear, @lijunyi2! Could you share your solution?


AJiaBoKe (@lijunyi2) · 2024-08-01

The file directory is like this:
![image|468x340](upload://ziKTOXCdKKAYTkWC4rOMUeSUiFF.png)

the `vercel.json` is like this:
```json
{
  "rewrites": [
    { "source": "/(.*)", "destination": "/api/index" }
  ],
  "functions": {
    "api/*.py": {
      "maxDuration": 60
    }
  }
}
```
`/api/index`, `index` is your file name。

I solved the python project, but the nodejs project is different from this. Do you have an example of how to set maxDuration in nodejs?