Browse Source

#1090: Tweaked docs for Python3 on Ubuntu

Jeremy Stretch 8 years ago
parent
commit
697866d1ba
3 changed files with 23 additions and 3 deletions
  1. 15 0
      docs/installation/netbox.md
  2. 3 2
      docs/installation/postgresql.md
  3. 5 1
      upgrade.sh

+ 15 - 0
docs/installation/netbox.md

@@ -8,6 +8,13 @@ Python 3:
 # apt-get install -y python3 python3-dev python3-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev
 # apt-get install -y python3 python3-dev python3-pip libxml2-dev libxslt1-dev libffi-dev graphviz libpq-dev libssl-dev
 ```
 ```
 
 
+!!! warning
+    On Ubuntu, installing only Python3 will not create a symlink for the interpreter at `/usr/bin/python`: scripts need to be called using the `python3` binary explicitly. As a workaround, you can create this symlink using the `update-alternatives` utility:
+
+        # update-alternatives --install /usr/bin/python python /usr/bin/python3 1
+
+    This will allow calling the `python3` binary as `python`.
+
 Python 2:
 Python 2:
 
 
 ```no-highlight
 ```no-highlight
@@ -84,6 +91,14 @@ Checking connectivity... done.
 
 
 Install the required Python packages using pip. (If you encounter any compilation errors during this step, ensure that you've installed all of the system dependencies listed above.)
 Install the required Python packages using pip. (If you encounter any compilation errors during this step, ensure that you've installed all of the system dependencies listed above.)
 
 
+Python 3:
+
+```no-highlight
+# pip3 install -r requirements.txt
+```
+
+Python 2:
+
 ```no-highlight
 ```no-highlight
 # pip install -r requirements.txt
 # pip install -r requirements.txt
 ```
 ```

+ 3 - 2
docs/installation/postgresql.md

@@ -5,13 +5,14 @@ NetBox requires a PostgreSQL database to store data. (Please note that MySQL is
 **Debian/Ubuntu**
 **Debian/Ubuntu**
 
 
 ```no-highlight
 ```no-highlight
-# apt-get install -y postgresql libpq-dev python-psycopg2
+# apt-get update
+# apt-get install -y postgresql libpq-dev
 ```
 ```
 
 
 **CentOS/RHEL**
 **CentOS/RHEL**
 
 
 ```no-highlight
 ```no-highlight
-# yum install -y postgresql postgresql-server postgresql-devel python-psycopg2
+# yum install -y postgresql postgresql-server postgresql-devel
 # postgresql-setup initdb
 # postgresql-setup initdb
 ```
 ```
 
 

+ 5 - 1
upgrade.sh

@@ -15,8 +15,12 @@ if [ "$(whoami)" = "root" ]; then
 	PREFIX=""
 	PREFIX=""
 fi
 fi
 
 
+# Fall back to pip3 if pip is missing
+PIP="pip"
+type $PIP >/dev/null 2>&1 || PIP="pip3"
+
 # Install any new Python packages
 # Install any new Python packages
-COMMAND="${PREFIX}pip install -r requirements.txt --upgrade"
+COMMAND="${PREFIX}${PIP} install -r requirements.txt --upgrade"
 echo "Updating required Python packages ($COMMAND)..."
 echo "Updating required Python packages ($COMMAND)..."
 eval $COMMAND
 eval $COMMAND