1

I have downloaded Python 3.6.2 (64 bit) in Windows 10 (64 bit). Now I want to work on Django framework so I want to download Django using pip command but it shows Error.

C:\Windows\system32>pip install django
Collecting django
  Using cached Django-1.11.4-py2.py3-none-any.whl
Collecting pytz (from django)
  Using cached pytz-2017.2-py2.py3-none-any.whl
Installing collected packages: pytz, django

Exception:

Traceback (most recent call last):
      File "c:\program files\python36\lib\site-packages\pip\basecommand.py", line 215, in main
        status = self.run(options, args)
      File "c:\program files\python36\lib\site-packages\pip\commands\install.py", line 342, in run
        prefix=options.prefix_path,
      File "c:\program files\python36\lib\site-packages\pip\req\req_set.py", line 784, in install
        **kwargs
      File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 851, in install
        self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
      File "c:\program files\python36\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files
        isolated=self.isolated,
      File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files
        clobber(source, lib_dir, True)
      File "c:\program files\python36\lib\site-packages\pip\wheel.py", line 316, in clobber
        ensure_dir(destdir)
      File "c:\program files\python36\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir
        os.makedirs(path)
      File "c:\program files\python36\lib\os.py", line 220, in makedirs
        mkdir(name, mode)
    PermissionError: [WinError 5] Access is denied: 'c:\\program files\\python36\\Lib\\site-packages\\pytz'
2
  • are you running your command prompt as administrator? Commented Aug 27, 2017 at 19:01
  • if ur running this pip command on cmd could u try running the cmd using run as administrator open? U have to right click the start button in task bar and select command prompt(Admin) option. Then try this command again Commented Aug 27, 2017 at 19:03

2 Answers 2

2

The problem has to do with the location you have chosen to install python, normally it's installed in C:\pythonXX but your installation is in C:\Program Files\pythonXX. That is always going to cause problems, you will need to always be running it as administrator. Quick and best solution, uninstall and accept to install python on the default location - C:\pythonXX

Sign up to request clarification or add additional context in comments.

Comments

1

The best way to work with Django is within a virtual environment. Installing packages in your system's Python 3.6 will affect all programs you have running on Python 3.6; if you have multiple Django apps, your requirements could get all mixed up.

Django works really nicely with virtual environments: there's a good tutorial here. Essentially, you want to set up a virtual environment for each project, and then install Django (and its dependencies) cleanly within that environment. This should avoid any "Access denied" or other errors that you're experiencing.

Just as an example of how virtual environments help: if you need to use different versions of Django for different apps, they should be limited only to apps within that same virtual environment. Then, you can install the package differently in a different environment for another app. That way, when you "import django" from one of your apps, you know you're getting the version you need.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.