Archive

Archive for May, 2017

pythonz: install any Python version in your HOME folder

May 20, 2017 3 comments

Problem
You want to install an older / newer version of Python. You don’t want to install it systemwide since you don’t want to mess up your system. How to install it in your HOME folder?

Solution
pythonz was made to address this problem. Install it and add an extra line to your .bashrc (see the docs). Some useful commands:

$ pythonz update           # self-update
$ pythonz list             # list of installed Python versions
$ pythonz list -a          # list of available (installable) Python versions
$ pythonz install 3.5.3    # install CPython 3.5.3
$ pythonz locate 3.5.3     # Where is it installed?

Here is how to create a virtualenv using a specific Python version that was installed with pythonz:

$ virtualenv -p $(pythonz locate 3.5.3) ~/.virtualenvs/project_name

I have a project in a virtual environment that works well with Python 3.5 (Ubuntu). Howeverm, under Manjaro the default Python is 3.6 and the project doesn’t work with it, it stops with some error. I didn’t want to dig in, so I installed CPython 3.5.3 with pythonz and used that version in the virtual environment. It works again :)

Categories: python Tags:

scraping Steam, get through the age check

Problem
You want to scrape Steam but sometimes Steam brings up an age check. How to get through it from a script? Examples: Fallout: New Vegas (age check), PST: EE (additional maturity check?).

Solution

import requests

COOKIES = {
    'birthtime': '283993201',
    'mature_content': '1',
}
URL = "http://store.steampowered.com/app/2028016/Fallout_New_Vegas_Ultimate_Edition/"

r = requests.get(URL, cookies=COOKIES)

Tip from here.

Categories: python Tags: , ,