Executing following commands in ubuntu terminal I have expected results:
echo $number ###3
>>>print(os.environ['number']) ###prints 3
$python -c 'import os;print(os.environ['number'])'
Make sure you change your single quotes for double quotes (the outer ones, at least) to avoid having that problem
python -c "import os;print(os.environ['number'])"
Works just fine because my single quotation marks are inside double quotes.
Edit: The problem with your example is not the fact that you're using single quotes within Python, the problem is that it's your shell that's interpreting those single quotes.
From the bash man page:
A single quote may not occur between single quotes, even when preceded by a backslash.