When I type python -m venv D:\(directory (not the actual directory)) on my terminal, the output File "<python-input-1>", line 1 appears and the command venv is marked in red with ^ below each letter and SyntaxError: invalid syntax message. But I’m sure that I’ve followed the Python documentation. Is it a kind of bug or I’ve typed a wrong command?
The same error also appear when I type pip install -r requirements.txt. The same output appears, but with install marked instead.
The prompt >>> indicates that you are working within the python REPL. This is running after you have started python without a script argument from the command line.
The commands you are trying are command line commands which you should enter in the Windows Terminal / Shell. There the prompt looks like C:\>.
In general we try to avoid Screenshots: They can not be “read”.
ChatGPT can elaborate on the information given above: Please try it out. E.g. by entering elaborate: <my whole first response from above>.
Try to understand the difference between the OS-shell and the Python interactive mode / REPL. The different prompts indicate which shell is active. Your pip commands go to the OS-shell with the prompt like C:\>.
Please try the following sequence:
type cmd + <Enter> in the Windows start menu: The OS text shell with prompt C:\> should appear.
enter there either py or python, depending on your installation:
The python interactive mode has started with the prompt >>>.
enter exit(): You leave the python shell and you are back in the OS shell.
try here in the OS shell the pip commands: e.g. either pip list or py -m pip list , depending on your installation
I don’t understand what does the error message means. It also mentions “torch”, in which i dont understand (again) what does the ‘torch’ means.
Or maybe I should use IPython mentioned in a page which the link is provided by Brian (as you told before)?
Sorry for replying lately again, because I’m busy working on anything else.
Now you have entered the pip command in the OS shell. That is the correct shell. Unfortunately you are facing a next different error. You are now a step further to your goal. Please also try to understand this error (once again e.g. by googling or asking ChatGPT etc.).
In short terms:
You instruct pip to install libraries listed in the requirements.txt.
As you can see on the pypi site torch does currently not support Python 3.13.1 (your installation). The latest currently by torch supported version is Python 3.12.x: see also this thread: Python 3.13.1 neither supports pytorch nor tensorflow
Then it would probably best if you de-install the Python 3.13.1 completely.
Otherwise you must be extra carefully to invoke the correct python version 3.12 since normally the newest version is started by py.exe!
I uninstalled Python 3.13.1 and install 3.12.8 (The last Python version that support TensorFlow and PyTorch).
When installing, I checked all the options in the installer.
Although I’ve checked pip, running a pip command will result “No module named pip”. Which means, pip is actually not installed.
I installed pip manually using py -m ensurepip --upgrade.
When running the command, the installation canceled automatically with the output “OSError: [WinError 225] Operation did not complete successfully because the file contains a virus or potentially unwanted software”.
Thanks to Kurt for the suggestion. I hope this will help those having problem with pip; especially those using PyTorch and TensorFlow. P.S. If you don’t use PyTorch and TensorFlow, reinstall your current Python or update to latest version instead of installing 3.12.8 version. P.P.S. If this doesn’t help (e.g. resulting another error), just create a new topic in this website. P.P.P.S. Previously, I thought that pip requires virtual environment (venv) until Brian sent me a link and Kurt suggest to use OS shell.