此处共有python noob。尝试学习python。我正在使用高塞拉<span class="indexmod">
{% assign number_of_words = content | strip_html | number_of_words %}
{% assign social = page.facebook | plus: page.instagram %}
{% comment %}Two lines for readability, but can be chained on one line{%
endcomment %}
{% assign Indexmod = social | times: page.age | divided_by: 1000000.0 %}
{% assign Indexmod = Indexmod | times: number_of_words | divided_by: 100
%}
{% endunless %}
</span>
的macosx并安装python 10.13.5
。我的任务是使用python运行mongodb查询,但无济于事,因为我正尝试使用Python 2.7.10
。
这是我看到的消息:(在命令行pymongo
上执行)
python mydev.py
我得到了相同的消息,仅使用 File "mydev.py", line 3, in <module>
import pymongo
File "/usr/local/lib/python2.7/site-packages/pymongo/__init__.py", line 77, in <module>
from pymongo.collection import ReturnDocument
File "/usr/local/lib/python2.7/site-packages/pymongo/collection.py", line 20, in <module>
from bson.code import Code
File "/usr/local/lib/python2.7/site-packages/bson/__init__.py", line 84, in <module>
from bson.dbref import DBRef
File "/usr/local/lib/python2.7/site-packages/bson/dbref.py", line 17, in <module>
from copy import deepcopy
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/local/Cellar/python@2/2.7.15_1/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
运行python shell并运行了脚本。
我的python脚本:
import pymongo
所以,我不知道该如何工作。我想念什么公斤?感谢您的帮助。
答案 0 :(得分:0)
给出的提示不是pymongo
,而是我的Mac上运行了多个版本的python的事实。经过更多研究,变得更加清楚了,拥有多个版本的python可能会引起问题。我读了这篇文章-https://docs.python.org/3/using/mac.html#ide
我能够像这样成功运行python脚本:
/usr/bin/python mydev.py