How do I find the version for datetime, math, win32com.client? - python

I tried the below code in Anaconda Prompt
import <module name>
print(<module name>.__version__)
print(<module name>.version.VERSION)
print(<module name>.version)
but get AttributeError: 'module' object has no attribute 'version' for each print.
Is it be'cos datetime, math, win32com.client are in-built library in Python? So how do I find their version?
Thank you

You can find the version of these modules in the Python3.x/Lib/__pycache__ folder.
As mentioned in the docs the version is available in this format module.version.pyc
Example: datetime.cpython-39.pyc means version 3.9
In fact, the version of the built-in modules is the same as the version of python.

Related

How to resolve "cannot import name clock" error in anaconda prompt? I am on Python 3.9.12

I am trying to run the HEX game program from:
https://github.com/masouduut94/MCTS-agent-cythonized
I am getting an error: ImportError: cannot import name clock
I am assuming this is because the clock() method has been removed in Python 3.8 and I am using 3.9.12.
How can I fix this?
I tried:
"from time import clock" but it is of no use as the method has been removed.
I tried:
pip install passlib==1.7.2
As answered in another similar query here, it did not help.

TypeError: a bytes-like object is required, not 'str' in geolite2 function in python

I have a program that displays the country belongs to the Ip address.Its working fine in version python 2.7.The problem is when i try the same program in version python 3.5 ,it throws an error as mentioned below:
Code:
from geoip import geolite2
m = geolite2.lookup('17.0.0.1')
Error:
TypeError: a bytes-like object is required, not 'str'
How can i resolve the error?
Thanks in advance
The answer above was correct to install the right package for Python3. To force installation for Python3 use:
python3 -m pip install python-geoip-python3
However, to benefit from the full functionality of geoip you may also consider downloading additionally geolite2 that also ships the IP database with it:
python3 -m pip install python-geoip-geolite2
To check if it works for you:
run python3 in interactive mode
run following:
>>> from geoip import geolite2
>>> geolite2.lookup('8.8.8.8')
You should get something like this
<IPInfo ip='8.8.8.8' country='US' continent='NA' subdivisions=frozenset({'CA'}) ...
you need to use the python 3 library:
pip install python-geoip-python3
I don't think the lib https://github.com/mitsuhiko/python-geoip will work in Python 3.x.
I looked at the source code in GitHub; it is 5 years without updates, and it still uses Python 2.x constructs (like xrange() in this line geoip.py#L255) that will not work in Python 3.x (maybe you get lucky and your code doesn't call the parts of the code with old constructs, but I wouldn't hold my breath).
It looks like you will have to clone the repo and adapt it to 3.x yourself or look for alternatives.

module 'skimage.filters' has no attribute 'gaussian_filter'

I'm trying to run this example, but getting the following error:
AttributeError: module 'skimage.filters' has no attribute 'gaussian_filter'
I checked the documentation, here, and see that filters has gaussian_filter. What might be wrong?
Thanks.
gaussian_filter has been removed in skimage 0.14.0 (see the release notes - http://scikit-image.org/docs/stable/api_changes.html). You should now use skimage.filters.gaussian (http://scikit-image.org/docs/0.14.x/api/skimage.filters.html#skimage.filters.gaussian).
I had a similar problem with the mahotas module, which was because of the version. Un-installed and re-installed an older version resolved the problem

Which version of python time module am I using

How do I determine which version of the python module 'time' is installed. For other modules .version.version or .__version__ work, however for time, both these methods return the error 'module' object has no attribute 'version' or 'version'
Module time is built-in in the Python interpreter. No other version than the interpreter's itself can be a valid answer (you can access that one using sys.version).
Other built-in modules like os, sys etc. also do not have their own version information.

ImportError: No module named numeric

I get the following error
ImportError: No module named numeric if I have the following import
from numeric import *
in my python source code. How do I get this running on my Windows box against a python 2.7.x compiler?
There is a module called numeric, but it's been deprecated for years in favour of numpy. You probably want to update your code to use numpy instead.
If you really need numeric, you can get it here, but you'll have to compile it from source for Python 2.7, because the latest binaries are for 2.4.
You will probably need to install this module: http://numpy.scipy.org/
There are binaries for windows too, so installation should be easy.
Josh
There is no common module called numeric. Are you sure you don't mean import numpy?

Categories