9

I have an installation of python on my C drive, but since I have no admin rights I am unable to install modules into the same.

error: could not create 'C:\Program Files\Python36\Lib\site-packages\yaml': Access is denied

I tried making a copy of the Python directory on the D folder and I changed the User environment variables to my path

D:\Program Files\Python36

But when I use pythonin the command prompt the python exe file in the C drive is executed and not the one in the D drive.

This same issue is arising in Visual Studio Code. Only the Python interpreter in C drive can be selected, the copy in the D drive is not shown.

The system environment path points to the python directory in C drive and cannot be changed (due to lack of admin rights), but the user enviroment variables are set to the python directory in D drive.

How can I make the python exe file in D drive as my default interpreter?

The account environment variable and path is attached

environment variable

Path

3 Answers3

11

This is most likely due to the path variable. You can see this in a command window by typing

Path

at your prompt.

To update the settings,

  1. Open the 'System' properties.

System Properties

  1. Open Environment Variables

Path Variables

  1. Highlight the 'Path' Variable and click edit.

Edit Path Variable

  1. Edit the values for the Python entries, to point to the desired python version.

enter image description here

  1. OK on all boxes, close any CMD windows open, and open new one. Python command should now reference the correct location.

Solution refers to Windows 10, but is essentially the same on Windows 7 +

Stese
  • 1,344
0

I was having the same issue as the older python executable was in my system space (which I have no access to) and the newer version is in the user space.

The work around I thought of was to create a .bat file which will open a CMD window in the user space python version.

new_python.bat:

@set "PATH=C:\Users\USER\AppData\Local\Programs\Python\Python39\;C:\Users\USER\AppData\Local\Programs\Python\Python39\Scripts\;%PATH%"
@cmd /k python --version

Does a decent job for me. Just change the first two lines in the PATH variable to your Python directory and the Python Scripts directory. The CMD which will open using this bat will be ready to run the newer version of python executable.

0

The problem is your python path might be old one in either user variable or system variable. Ascertain the version you want it is the same in both. e.g. in user variables path has C:\Users\452209\Python3.8\Scripts
C:\Users\452209\Python3.8\

Then in system variables the path should also be of same version i.e.

C:\Users\452209\Python3.8

Do this, it will solve your issue

Happy Learning