0

I have some python code I use for emails that recently stopped working. Trying to debug it, I discovered that imaplib.IMAP4_SSL exists in python started from an anaconda prompt, but not a regular windows command prompt. How is this possible?

Here's the simplest way I know to show:

  1. open anaconda prompt and windows command prompt
  2. in both prompts, type 'python' to start python
  3. both show the same python version (3.7.1 for me)
  4. type the following:

import imaplib
imaplib.IMAP4_SSL

The anaconda prompt returns a class and works fine, while the windows cmd prompt returns an error:

AttributeError: module 'imaplib' has no attribute 'IMAP4_SSL'

I thought maybe I had multiple versions of python installed, so I uninstalled everything related to python that I could find, then reinstalled anaconda. It didn't help.

  • Another post mentioned that ssl needs to be available, so maybe I have an ssl problem instead of an imaplib problem. I can import ssl in the anaconda prompt, but not the windows cmd prompt. – Nathan Tomlin Jan 28 '19 at 20:57

1 Answers1

0

I found a workaround in this post by using a batch file. Now I can get my code to work by double clicking in windows. This is the batch file that works for me (in directory with code):

set root=C:\Users\usernamen\AppData\Local\Continuum\anaconda3
call %root%\Scripts\activate.bat %root%
call PythonFileToRun.py
pause

I still don't understand what the activate.bat file does or why ssl doesn't work in the windows cmd prompt though.