4

I am simply trying to do this

from IPython.lib import passwd

but I get this error

In [1]: from IPython.lib import passwd
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Input In [1], in <cell line: 1>()
----> 1 from IPython.lib import passwd

ImportError: cannot import name 'passwd' from 'IPython.lib' (/home/ubuntu/anaconda3/lib/python3.9/site-packages/IPython/lib/__init__.py)

Googled the error but nothing.

justanewb
  • 133
  • 4
  • 15

3 Answers3

4

I am facing the same issue with IPython version 8.4. It seems to me that the security lib is not present anymore. If you are using version 7x you should be able to import it with

from IPython.lib.security import passwd

as denoted in https://ipython.readthedocs.io/en/7.x/api/generated/IPython.lib.security.html?highlight=passwd

However, from version 8x the module security is missing...

1

The version 8x changed this again, as noted by @Blitzbirnep, but the new module is mentioned in the documentation

from notebook.auth import passwd
hash=passwd('example')

Please note that the default hashing algorithm is no more SHA1, so if you want exactly the old behavior you need to add another parameter.

from notebook.auth import passwd
hash=passwd('example', 'sha1')
eMMe
  • 569
  • 5
  • 16
0

try it, worked for me.

import IPython.lib.security as security
security.passwd()

Code and output

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
FerT
  • 1
  • 1