码迷,mamicode.com
首页 > 数据库 > 详细

设置MongoDB课程环境

时间:2018-02-04 22:36:19      阅读:241      评论:0      收藏:0      [点我收藏+]

标签:resource   pen   ade   cluster   ike   intro   sum   doc   get   

Setting Up Your Course Environment

This course is designed to be very hands on. Virtually all of the lectures have resources that can be downloaded so that you can follow along with the instructor. These resources are listed below the lecture video underneath "Downloads".

Prerequisites

Before following the instructions below you should make sure you‘ve completed the following prerequisites.

Course Directory Structure

You‘ll likely be downloading many files as you progress through the course. To keep all of these files organized we suggest you create a folder structure like so:

.
└── mongodb-analytics
    └── intro-to-mongodb
        ├── mflix
        └── notebooks
 

The "mongodb-analytics" folder is used to segment the different courses in this specialization. So you can create a folder inside of that called "intro-to-mongodb" for this course‘s downloadable resources. The notebooks folder is for all of the notebooks and datasets that you download. And finally, there‘s the the mflix folder which will hold the mflix app that you‘ll download and install later in the course.

Jupyter Notebooks

Many of the resources you download will be Jupyter notebooks that you can run locally on your computer. The following sections will walk you through how to install and set up your Juyter notebook environment.

We‘re going to use Anacanoda to install Python 3 and to manage our Python environment. You can download Anaconda from their download site. After downloading the installer you can run it to install Python 3 and Anaconda‘s commandline tools.

You‘ll want to create an Anaconda environment for all your Python dependancies. Run this command from inside the intro-to-mongodb folder.

conda create -n intro-to-mongodb

 

You can then activate this environment by running:

source activate intro-to-mongodb # on Linux and macOS
activate intro-to-mongodb # on Windows

 

Then from inside your notebooks directory you can run the following command to start your Jupyter notebook:

jupyter notebook

 

From there, you should be able to point your browser to http://localhost:8888/ to access the Jupyter Notebook interface. Now, any notebooks (ipynb files) that you place in the notebooks directory will appear and be executable in this interface.

Installing Python Dependancies

You now have an environment set up where you can execute the handouts from the lectures and assessments. Some of the notebooks that you‘ll download will use 3rd party Python modules. A great example of this is pymongo, which is the Python module that allows your scripts to talk to a MongoDB database.

To install 3rd party Python modules you‘ll use the pip command, which is installed alongside Python via Anaconda. By default, pip installs Python modules globally. To prevent polluting your global Python environment you‘ll want to install all the modules used in this course inside your Anaconda environment.

For example, if you wanted to install pymongo you‘d do something like the following:

# This assumes your mongodb-analytics folder is stored in your home directory
cd ~/mongodb-analytics/intro-to-mongodb
source activate intro-to-mongodb # on macOS and Linux
activate intro-to-mongodb # on Windows
pip install pymongo dnspython
 

After executing the following commands you‘ll be able to use the pymongo module to connect your Jupyter notebooks to MongoDB!

设置MongoDB课程环境

标签:resource   pen   ade   cluster   ike   intro   sum   doc   get   

原文地址:https://www.cnblogs.com/huahuayu/p/8414208.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!