我是 Windows 用戶,也是 Ubuntu 和 DigitalOcean 新手。我完成了中的步驟
https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-12-04
我正在經歷
但它失敗pip install django
了
OSError: [Errno 13] Permission denied: '/opt/myenv/build'
追溯:
(myenv)jeffy@originaldjangster:~$ pip install django
Downloading/unpacking django
Cleaning up...
Exception:
Traceback (most recent call last):
File "/opt/myenv/local/lib/python2.7/site-packages/pip/basecommand.py", line 1 22, in main
status = self.run(options, args)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/commands/install.py", l ine 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundl e=self.bundle)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 1153, in prepare_files
location = req_to_install.build_location(self.build_dir, not self.is_downloa d)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 218, in b uild_location
_make_build_dir(build_dir)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 1527, in _make_build_dir
os.makedirs(build_dir)
File "/opt/myenv/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/myenv/build'
Storing debug log for failure in /home/jeffy/.pip/pip.log
調試日誌:
jeffy@originaldjangster:~$ more /home/jeffy/.pip/pip.log
------------------------------------------------------------
/opt/myenv/bin/pip run on Tue Aug 5 14:45:38 2014
Downloading/unpacking django
Cleaning up...
Exception:
Traceback (most recent call last):
File "/opt/myenv/local/lib/python2.7/site-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 1153, in prepare_files
location = req_to_install.build_location(self.build_dir, not self.is_download)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 218, in build_location
_make_build_dir(build_dir)
File "/opt/myenv/local/lib/python2.7/site-packages/pip/req.py", line 1527, in _make_build_dir
os.makedirs(build_dir)
File "/opt/myenv/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/opt/myenv/build'
jeffy@originaldjangster:~$
視覺:
#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
Defaults mail_badpass
Defaults secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL:ALL) ALL
jeffy ALL=(ALL:ALL) ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
# Allow members of group sudo to execute any command
%sudo ALL=(ALL:ALL) ALL
# See sudoers(5) for more information on "#include" directives:
#includedir /etc/sudoers.d
我跳過了問題步驟並成功繼續,直到pip install gunicorn
,此時我遇到了相同的錯誤:
OSError: [Errno 13] Permission denied: '/opt/myenv/build'
僅供參考:我按照指示在已啟動的 virtualenv 中執行此操作。
我究竟做錯了什麼?感謝您的協助。
以上是我的首要問題。如果以下問題很容易回答,請另外回答。這是我弄清楚上述問題後需要立即採取的步驟:
我還需要知道如何從 Python 2.7.6 升級到 Python 3.4.1(或可用的 Ubuntu 相容的最高版本)。 Python 已經安裝了——我沒有安裝它。
我只想擁有 3.4.1。我不希望 2.7 和 3.4 並排。
jeffy@originaldjangster:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04.1 LTS
Release: 14.04
Codename: trusty
jeffy@originaldjangster:~$ python --version
Python 2.7.6
答案1
數位海洋支援:
因此,無論您的使用者是否設定為能夠在 visudo 中執行所有命令,您仍然需要在所有命令中新增「sudo」。
關於Python,2.7版本根本無法刪除。如果您想使用 Python 版本 3.xx,則需要使用指令 python3。
我:
看來就是這樣了。 “如何安裝”指南
https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-django-with-postgres-nginx-and-gunicorn
在“pip”命令之前沒有“sudo”前綴,而且看起來應該有。看起來 3.4 也已經安裝了。出色的。
更新
事實證明上述還不夠好。雖然安裝了ipython,但並沒有安裝在虛擬環境中--根本沒有ipython
建立目錄。/opt/jenv/bin
以這種方式安裝時,在我的環境中,無論如何,啟動 IPython 使用的是 Python 2.7,而不是 3.4。 (這就是它啟動時所說的)。
解決方案是啟動virtualenv,然後使用虛擬環境的點:
sudo /opt/jenv/bin/pip install ipython
(提醒一下,如果沒有sudo
,這將不起作用 - 請參閱問題。)IPython 現在已正確安裝在 bin 目錄中,並且在啟動時,表示它正在使用 Python 3.4(只要使用 建立 virtualenv -p /usr/bin/python3.4
)。
它似乎這些說明需要改變。