Project

General

Profile

Support #876

Install a Python 2.7 Development Environment on Arch Linux

Added by Daniel Curtis over 7 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Python
Target version:
Start date:
11/29/2016
Due date:
% Done:

100%

Estimated time:
0.50 h
Spent time:

Description

This is a guide for setting up a simple development environment for Python 2.7 with virtualenv on Arch Linux.

Prepare the Environment

  • Make sure the system is up to date:
    pacman -Syyuu
    

Install Python

  • Install python and a few dependencies:
    pacman -S python2 python2-{pip,pkgconfig,setuptools,virtualenv}
    
  • Create a non-privileged user to develop with:
    useradd -m -g users -s /bin/bash -c "Python Dev" pydev
    passwd pydev
    

Use Python2 Explicitly

  • Switch to the python dev user:
    su - pydev
    
  • First create a bin folder in the pydev user home directory:
    mkdir ~/bin
    
  • Then add a symlink python to python2 and the config scripts in it:
    ln -s /usr/bin/python2 ~/bin/python
    ln -s /usr/bin/python2-config ~/bin/python-config
    
  • Finally put the new folder at the beginning of your PATH variable:
    echo 'export PATH=~/bin:$PATH' >> ~/.bash_profile
    
  • Exit from the pydev user session:
    exit
    

Create Virtualenv

  • Switch to the python dev user:
    su - pydev
    
  • Create a new virtualenv called new_app:
    virtualenv2 new_app
    
  • Activate the new_app virtualenv to begin using it:
    source ./new_app/bin/activate
    
  • Install or develop the new_app:
    pip install new_app
    
  • When done working in the virtual environment for the moment, deactivate it:
    deactivate
    

wxPython in virtualenv

  • Switch to the python dev user:
    su - pydev
    
  • Activate the new_app virtualenv to begin using it:
    source ./new_app/bin/activate
    
  • Install wxpython:
    pip install wx
    
  • Deactivate and reactivate new_app virtualenv to refresh libraries:
    deactivate
    source ./new_app/bin/activate
    

Test wxPython in virtualenv

  • Start an iPython session:
    ipython
    
    • And use the following code example to test windows
      import wx
      app = wx.App(False)
      frame = wx.Frame(None, wx.ID_ANY, "Running from virtualenv!")
      frame.Show(True)
      app.MainLoop()
      

Resources

#1

Updated by Daniel Curtis over 7 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100
#2

Updated by Daniel Curtis over 7 years ago

  • Subject changed from Install a Python Development Environment on Arch Linux to Install a Python 2.7 Development Environment on Arch Linux
  • Description updated (diff)
#3

Updated by Daniel Curtis almost 7 years ago

  • Status changed from Resolved to Closed
#4

Updated by Daniel Curtis about 6 years ago

  • Description updated (diff)

Also available in: Atom PDF