Pymongo issue in a python project -


i have installed pymongo, , when start new project , write import pymongo python shows me next error.

python version: 3.4.3

error code

traceback (most recent call last):   file "testmongodb.py", line 3, in <module>     import pymongo importerror: no module named 'pymongo' 

pymongo

if put code python -c "import pymongo; print(pymongo.version); print(pymongo.has_c())" terminal, shows next information.

3.0rc1 true 

i'm trying execute python code via terminal command

python3 testmongodb.py

input

python -c "import pymongo; import sys; print(pymongo.version); print(pymongo.has_c()); print (sys.path)" 

output

3.0rc1 true ['', '/library/python/2.7/site-packages/pip-6.1.1-py2.7.egg', '/library/python/2.7/site-packages/pymongo-3.0rc1-py2.7-macosx-10.10-intel.egg', '/system/library/frameworks/python.framework/versions/2.7/lib/python27.zip', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-old', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python/pyobjc', '/library/python/2.7/site-packages'] 

input python code

# include mongo library. import pymongo  # include sys library. import sys  print (sys.path) 

output python code

['/users/ismaelmoral/python/testmongodb', '/library/python/2.7/site-packages/pip-6.1.1-py2.7.egg', '/library/python/2.7/site-packages/pymongo-3.0rc1-py2.7-macosx-10.10-intel.egg', '/system/library/frameworks/python.framework/versions/2.7/lib/python27.zip', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-darwin', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-tk', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-old', '/system/library/frameworks/python.framework/versions/2.7/lib/python2.7/lib-dynload', '/system/library/frameworks/python.framework/versions/2.7/extras/lib/python/pyobjc', '/library/python/2.7/site-packages'] 

it seems have installed pymongo python 2, trying run using python 3. need install python 3.

you can see command works uses python whereas 1 fails uses python3. can verify problem checking works:

python testmongodb.py 

and fails:

python3 -c "import pymongo; print(pymongo.version); print(pymongo.has_c())" 

solution

i'll assume use pip install packages. need use pip python 3 installation rather 1 on default path python 2.

go directory \root\dir\for\python3x\scripts. run pip find in there, e.g. ./pip install pymongo , install python 3

if solution doesn't meet needs - have @ pymongo installation docs.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -