本文介绍了在Mac OS X上mongoimport安装在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置cronjob以便将json数据定期排入mongo数据库.为了进行导入,我在cronjob运行的Python脚本中有以下命令:

I'm trying to setup a cronjob for a regularly scheduled import of json data into a mongo database. To conduct the import, I have the following command in the Python script that the cronjob runs:

os.system("mongoimport --jsonArray --db %s --collection %s --file .../data.txt" %(db_name,collection_name))

但是,cronjob的日志文件始终显示以下错误:

However, the log file of the cronjob keeps displaying the following error:

sh: mongoimport: command not found

我认为我需要在代码中使用完整的文件路径来调用mongoimport,但是我不确定在我的系统上安装了mongodb/mongod/mongoimport的位置. whereis mongoimport,whereis mongodb,whereis mongod均不返回任何内容.

I think I need to call mongoimport with the full file path in the code, but I'm not sure where mongodb/mongod/mongoimport is installed on my system. whereis mongoimport, whereis mongodb, whereis mongod all return nothing.

我用Homebrew安装了mongodb.与Homebrew一起安装的软件包位于/Library/Caches/Homebrew中.但是,在我的系统中,该文件夹仅具有mongodb-2.6.4_1 tar文件.我必须解压缩此tar文件才能访问mongoimport吗?

I installed mongodb with Homebrew. Packages installed with Homebrew are located in /Library/Caches/Homebrew. However, in my system that folder only has a mongodb-2.6.4_1 tar file. Do I have to unpack this tar file to access mongoimport?

感谢您的帮助.

推荐答案

如果正确安装了MongoDB,则需要创建~/.bash_profile并将/usr/local/mongodb/bin分配给$PATH environment variable

If you installed MongoDB correctly you need to create a ~/.bash_profile and assign /usr/local/mongodb/bin to the $PATH environment variable

之后,您应该可以访问mongoimport命令

After that you should be able to access the mongoimport command

这篇关于在Mac OS X上mongoimport安装在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 23:03