I’m having some issues with backslashes in my scripts and in python in general. I am using the latest version of python.
I downloaded python to an external drive because I lack some storage space.
Using command prompt
D:\python-lang>python.exe pip install numpy
python.exe: can't open file 'D:\\python-lang\\pip': [Errno 2] No such file or directory
That command should be:
python.exe -m pip install numpy
Thanks that worked and do you know what should I do about the backslashes it is the same as the path file.
The doubled backslash in the path is not an error. It is because
\ is the escape character for python strings: e.g.
\n represents a newline character, and
\t represents a tab. Because of this, typing a literal backslash in a string must also be escaped:
Windows uses the backslash for path separation, and so when python shows you the raw representation of the path, it shows the backslash as
\\ to denote that it is a literal backslash and not an escaped character. If you
print that string, you’ll see it’s only one backslash, not two.
If you open python in an interactive session (e.g. just type
python.exe) you can play around with this:
>>> s = "here's a backslash \\"
"here's a backslash \\"
here's a backslash \