Python - Importing pandas in console works but not

2019-09-12 00:14发布

问题:

I've been working with anaconda3/python3.5 and pandas for over a year and all of sudden when I run my script outside the console, I get a import error for pandas particularly the dependency email.parser. I get No module named 'email.parser';'email' is not a package. However importing in the console works fine. I'm not running any other environment

回答1:

I also had the same problem today. You're missing a specific path. Found that if you start your python interpreter and do import os, you can do os.environ. You'll notice that there are several paths set in the PATH variable. Copy/paste the entire PATH line into your script. That worked for me. Also, remember to remove string single quotes (e.g., ').