26

I'm developing a python project, in the requirements file I have three different types of PyMongo

Flask-PyMongo==0.3.1
pymongo==2.7
flask-mongoengine==0.7.1

How can I define which version I'm using?

Kara
  • 6,115
  • 16
  • 50
  • 57
Babel
  • 589
  • 2
  • 9
  • 23

7 Answers7

38

If you got pip installed, you can try this in terminal:

$ pip freeze | grep pymongo
pymongo==3.0.2
Kane Blueriver
  • 4,170
  • 4
  • 29
  • 48
  • The result of that command is: pymongo==3.0, none of them above! – Babel Aug 26 '15 at 08:48
  • @Egzona So, that's the version of pymongo you've installed. You can force to install it by ``pip install pymongo==2.7``, ``sudo`` maybe required. BTW, virtualenv is suggested to isolate different projects' environments, although not needed. – Kane Blueriver Aug 26 '15 at 08:52
21

You can learn like this,

>>> import pymongo
>>> pymongo.version
'3.0.3'
Adem Öztaş
  • 20,457
  • 4
  • 34
  • 42
  • Also for this command result is: pymongo==3.0, none of them above! – Babel Aug 26 '15 at 08:51
  • I have installed 3.0.3, depends your installation. What is your results? – Adem Öztaş Aug 26 '15 at 08:55
  • After executing your command result is: pymongo==3.0, but in my project in requirement file version of it is different, I can't understand why is happening this? – Babel Aug 26 '15 at 09:03
7

This should work

python -c 'import pymongo; print (pymongo.__version__)'
Charan
  • 83
  • 1
  • 6
3
import pymongo
print("Mongo version",pymongo.__version__)

Works perfectly in python3

Shaurya Uppal
  • 3,410
  • 31
  • 31
1
pip list | grep pymongo

or

pip freeze | grep pymongo
7wick
  • 411
  • 4
  • 17
0

open the command prompt IF your python path is set , simply write pip freeze it shows the versions of all packages installed , including pymongo

Nyma
  • 21
0

Similar to grep; For Windows installs using Conda environments with pip this worked for me:

pip freeze | findstr /si pymongo 
Lelouch
  • 549
  • 6
  • 6