Generally speaking, JavaScript scripts are not given direct access to hardware by the browser. This would be an enormous security vulnerability; imagine going on to a website and it can then access everything connected to your computer. Not good.
That said, you can still achieve what you want a slightly different way. Your Pi needs to be a web server; you could use a library such as Python's Flask to serve up a simple web API. Then your client-side scripts can simply send a request to your Pi server, which then fetches the data through Python. A trivial example would be as follows:
from flask import Flask
app = Flask(__name__)
@app.route("/humidity")
def humidity():
humidity = get_humidity_through_python()
return humidity
The implementation is for you to do what you like; the code simply illustrates the point that you can serve a web page from a server in this fashion.
For a stream of data, you might consider sending the data over a Web Socket. JavaScript can connect to those, so you simply allow clients to run some JavaScript to connect to your web socket, then process the data with P5.