设置MongoDB课程环境

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!

转载于:https://www.cnblogs.com/huahuayu/p/8414208.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值