can not add python to the path of environment variable - python

I have the same old problem of python not being recognized and get this error in VS:
[Running] python -u "c:\Users\Keram\Desktop\WEB\index.py"
'python' is not recognized as an internal or external command,
operable program or batch file.
the solution is said to be putting the path of the python file where it is installed in the PATH of the environment.
but I had the same issue with node.js and had to put its path as the environment variable path.
now if I add python's path, I would not have node.js.
what am I supposed to ?

You can set path for node and python both, it doesn't affect anything.
Just go to environment variables, click path, edit, and then add the path of python executable file.
Then just restart/reopen the terminal and check.
I had the issue with python where the name was python3 not the python
Renaming solved that issue too.
Hope it helps.!

Related

cant activate virtual env through vs windows 11 python 3.10.4

Was just trying out making an environment via python and Django, but i keep running into this issue where the python interpreter does not seem to understand.
I have use source bin/activate as well, but to no avail.
.\test.com_env\Scripts\activate.ps1 :
The term '.\test.com_env\Scripts\activate.ps1' is not recognized
as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included,
verify that the path is correct and try again.
At line:1 char:1
.\test.com_env\Scripts\activate.ps1
Had the same problem on Windows 10. My solution was: From the outer folder to the virtual environment folder, I performed the following command line:
You can try:
.\test.com_env\Scripts\activate
I didn't have to add the extension.ps1.
You should check the location from where the above command line is being executed.

Getting error in VS code when trying to create virtual environment on windows

I am trying to create a virtual environment in VS code to make a flask app. After I run the command in the VS code terminal pip install virtualenv everything downloads find but I get the error WARNING: The script virtualenv.exe is installed in
C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Then when I try to create my virtual environment by using this command virtualenv env I get the error
virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Are you using Python from the Windows Store? You'd better avoid it.
You can download the python from the official site.
And then create the virtual environment through venv.
You can refer to official docs for more details of the virtual environment created.
This is happening because the directory (as mentioned by you)
C:\Users\NAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\Scripts' which is not on PATH.
is not added to your PATH
Consider this link Add to the PATH on Windows 10 and add the directory to the PATH.
It's gonna solve your problem.
The same issue happened to me it solve it as said above.

Trying to access Python through Windows Command Prompt without adding Environment Variable

I am trying to access Python through a Windows command prompt, but am at an office and cannot add an Environment Variable. So, I cant follow the advice provided here. Thus, I added a User Environment Variable through User Accounts and use Variable:python and Value: C:\Python33. When I do a Windows Run check on %python% I reach the required Python33 folder. However, when I type python -Version in the command prompt I get the error 'python' is not recognized as an internal or external command, operable program or batch file. I am not sure how to proceed.
Run Python from the command prompt and include the full path to python.exe. For example to get the version:
C:\Python33\python.exe --version
When you run a script you specify the path to the script if you're not in the directory where the script is located. For example, if your script is in C:\scripts and is called my_script.py:
C:\Python33\python.exe C:\scripts\my_script.py
Instead of setting environment variables, you can use the whole path, like Neo wrote e.g.:
C:\Python33\python.exe yourPythonScript.py
Remove any environment variables you have added.
C:\Python33\python.exe pyscript.py should work.
I once Had a similar problem, but i couldnt find any solution, not even adding the path to the python folder was working.
Then I opened Python and clicked in File, then browser path, and I found that I had another folder that contained the real Python folder, not the default one. Maybe it could work for you too.

Environmental path to Python not working?

I have Installed Python 3.4 onto a new PC. Python works but I am trying to get pip to work on this. I have made a path for Python which is below.
C:\Python34\python.exe
When i run the below code
C:\Windows\System32>pip install python-docx
'python' is not recognized as an internal or external command,
operable program or batch file.
It seems that you haven't configured your PATH variable correctly. In order to do so:
Hold down the Win key and press Pause.
Click Advanced System Settings.
Click Environment Variables.
Append ;C:\Python34 to the PATH variable.
Restart Command Prompt.
(You may also just run set PYTHONPATH=%PYTHONPATH%;C:\Python34 in the cmd)
Further information is available in The Official Python Installation Guide for Windows.

Add “python2” path to command line on Windows 7

I've been trying to add the python2 path to command line on Windows 7.
I have tried to do it this way:
C:\>set python2 = C:\Python27\python.exe
But cmd told me that:
'python2' is not recognized as an internal or external command.
So how can I add python2 path to command line on Windows 7?
Thanks.
This answer copied from my own answer, and customized to this question.
Try following command.
set path=%path%;c:\python27
PATH is set only for the cmd.exe in which you run the above command.
To permanently set PATH:
Right click My computer in the desktop.
Click Advanced System Settings on the left.
Click Environmental Variable.
Add or Update PATH variable:
If it does not exist, create one, and set value as C:\python27
If it exist, append ;C:\Python27 to existing value.
Restart cmd.exe. (PATH will not change for already launched cmd.exe)
UPDATE
If you want to use python2, copy the executable.
CD C:\python27
COPY python.exe python2.exe
Had the same problem and fixed it...
I have C:\Python27, which i have added to my environment variables which gave me access to "python" though the CMD.. but for installing node-sass though npm, which was my problem, it continues to say that "python2" is not found. A friend the told me i could just rename name executable, which i didn't belive, but it worked :-)
The rename was from:
C:\Python27\python.exe > C:\Python27\python2.exe
It works for me, even though it find it weird just renaming a file.. but then, i am not hardcore in the windows CMD.
I don't know whether it can be switched or not while keeping both python2 and python3.
But while working with python2 you can remove the "python3 path" from the PATH.
Cause By default in windows python3 is selected if both are installed.
So you can try this to use python2. then when necessary again add the "python3 path " to the PATH
although I add Python to path variable, it appeared further, I tried with Thor A. Pedersen's answer it worked, I found another way without rename python.exe to python2.exe, just update your node config as bellow. It worked for me.
npm config set python python2.7
or
npm config set python python

Categories

Resources