簡體   English   中英

在Python 3.6.2上部署Django

[英]Deploy Django on Python 3.6.2

我在Windows 10(64位)中下載了Python 3.6.2(64位)。 現在我想開發Django框架,所以我想使用pip命令下載Django,但它顯示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

例外:

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'

問題與您選擇安裝python的位置有關,通常它安裝在C:\\ pythonXX中,但您的安裝位於C:\\ Program Files \\ pythonXX中。 這總是會導致問題,您需要始終以管理員身份運行它。 快速和最佳解決方案,卸載並接受在默認位置安裝python - C:\\ pythonXX

使用Django的最佳方式是在虛擬環境中。 在系統的Python 3.6中安裝軟件包將影響在Python 3.6上運行的所有程序; 如果你有多個Django應用程序,你的要求可能會混淆。

Django的作品真的很好地與虛擬環境:有一個很好的教程在這里 實際上,您希望為每個項目設置一個虛擬環境,然后在該環境中干凈地安裝Django(及其依賴項)。 這應該避免任何“拒絕訪問”或您遇到的其他錯誤。

僅作為虛擬環境如何幫助的示例:如果您需要為不同的應用程序使用不同版本的Django,它們應僅限於同一虛擬環境中的應用程序。 然后,您可以在另一個應用程序的不同環境中以不同方式安裝該程序包。 這樣,當您從某個應用程序“導入django”時,您就知道自己獲得了所需的版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM