Python exception handler to recommend package
An ImportError instance doesn't have a replace method.

You can use e.name instead of messy string replacements.



Instead of '%s' % x, it's recommended to use '{}'.format(x).



The example output is not what you posted, but actually this:


  'Error: Try sudo pip install Crypto'


That is, it's surrounded by single quotes, because you wrote as "'some text'".
Probably you want to remove those single quotes inside the string.



What does the message even mean?

This would make a lot more sense:


  Error: could not import 'Crypto'. Try installing with: pip install --user Crypto




Last, but most importantly, please don't recommend to install Python packages system-wide. This is a more sensible recommendation:

pip install --user the_package


This doesn't need sudo, as it will install the package in the user's home directory, not system-wide.



Putting it together:

try:
    import somename
except ImportError as e:
    sys.exit("Error: could not import '{0}'. Try installing with: pip install --user {0}".format(e.name))