Clarify that `uv run python` gets you a REPL
We could also provide another way to do this, eventually? Maybe just python when we have a shim. Maybe a bare uvx.
@zanieb
Updated the docs and added the uv run python section in docs/scripts.
I just have a question regarding the use of single scripts projects... So for example:
In: main.py
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "numpy",
# "pandas",
# ]
# ///
import numpy
import pandas
def main():
pass
if __name__ == '__main__':
main()
print('Done!')
Then using uv produces no errors:
user@pop-os:~/Documents/GitHub/standalone_scripts$ uv run main.py
Reading inline script metadata from: main.py
Done!
However when trying to get a REPL after an execution (maybe inspect some variables or have imports ready):
user@pop-os:~/Documents/GitHub/standalone_scripts$ uv run python -i main.py
Traceback (most recent call last):
File "/home/user/Documents/GitHub/standalone_scripts/main.py", line 9, in <module>
import numpy
ModuleNotFoundError: No module named 'numpy'
>>>
@Michallote we just don't support that yet! i.e., we don't read the metadata because you invoked python not the script itself. We can track that at https://github.com/astral-sh/uv/issues/8064
When I run uv run python, I get an interactive REPL as expected. However, changes to the source code aren’t reflected immediately — even re-importing the modules doesn’t help. I have to exit and restart the REPL to see the updates. The same issue occurs with ipython, even when using %autoreload. Is this expected behavior?
@IliasAarab could you open a new issue with a minimal reproduction?
@zanieb thanks for the response, see #12373