5

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

1

3 Answers 3

4

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 +

5
  • 1
    I have made the changes in PATH for the user the path points to the desired python interpreter, but I cannot change the system variables. Still when I run python command the earlier (C drive) interpreter is used Jan 29, 2019 at 8:49
  • 1
    Try a reboot if you haven't already... How are you launching the python file?
    – Stese
    Jan 29, 2019 at 9:05
  • 1
    I've tried rebooting, but to no gain. I run the python executable using "python" command and tried installing module using "python setup.py install" Jan 29, 2019 at 11:03
  • 1
    Hmm, Can you screenshot the path variable?
    – Stese
    Jan 29, 2019 at 11:35
  • 1
    I have attached the screenshot of the path variable in the question Jan 30, 2019 at 4:35
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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.