Month: November 2018

Setup MongoDB on iOS

A simple guide to setting up MongoDB on iOS.

  1. Objectives:
      1. Install MongoDB on MacBook.
  2. Required Tools:
      1. Homebrew —  package manager for Mac
      2. MongoDB — MongoDB community version
      3. pymongo — python API for MongoDB.
  3. Steps (terminal command in blue):
      1. brew update
      2. brew install mongodb
      3. Create MongoDB Data directory (/data/db) with updated permission
        1. $ sudo mkdir -p /data/db
        2. $ sudo chown <user>/data/db
      4. Create/open bash_profile
        1. $ cd to users/<username>
        2. $ touch .bash_profile # skip if .bash_profile present
        3. $ open .bash_profile
      5. Insert command in  bash_profile for MongoDB commands to work in terminal
        1. export MONGO_PATH=/usr/local/mongodb
        2. export PATH=$PATH:$MONGO_PATH/bin
      6. Test: Run MongoDB
        1. terminal 1: mongod
        2. terminal 2: mongo.
      7. Install pymongo
        1. pip install pymongo

Further notes 

Advertisements

Fast Install Python Virtual Env in Windows

A simple guide to install virtual environment with different python version on Windows.

  1. Objectives:
      1. Install Virtual Environment on Windows
  2. Required Tools:
      1. Python —  Python 3 chosen in this case.
      2. VirtualEnv — Main virtualenv tool.
      3. VirtualEnvWrapper-Win — VirtualEnv Wrapper for Windows.
  3. Steps:
      1. Install python with python windows installer.
      2. Add python path to Windows PATH. Python 3 will enable this option for users. If not found, add the following two path (Python 3 sample default path )
        1. C:\Users\\AppData\Local\Programs\Python\Python36
        2. C:\Users\MyUserName\AppData\Local\Programs\Python\Python36\Scripts
      3. pip install virtualenv
      4. pip install virtualenvwrapper-win
      5. Main commands use with virtualenv wrapper in windows command prompt
        1. mkvirtualenv : create a new virtual env
        2. workon : list all the environment created
        3. workon  : Activate particular environment.
        4. deactivate: deactivate active environment
        5. rmvirtualenv : remove target environment.

Further notes 

  • Most of the guide reference from Timmy Reilly’s Blog.
  • To create virtualenv with specified python version
    • virtualenv -p <path/win dir of python version>
    • mkvirtualenv -p <path/win dir of python version>
  • Retrieve a list of python modules installed via pip and save to requirement.txt
    • pip freeze > requirement.txt
  • to install a list of required modules (from other virtual env etc)
    • pip install -r requirements.txt