I'm working in a virtual environment. In terminal, I can do:
>>> from pytz import timezone
without issue. However, when I try to run the same code from a python file, I get:
ImportError: No module named pytz
[Finished in 0.0s with exit code 1]
[shell_cmd: python -u "/Users/<user>/Desktop/<project folder>/<python file>.py"]
[dir: /Users/<user>/Desktop/<project folder>]
[path: /usr/bin:/bin:/usr/sbin:/sbin]
Since I'm working in a virtual environment, why isn't it finding the pytz module? It seems like it's only looking in the usr/bin, /bin, etc folders. I even installed it like this outside my virtual environment:
pip install -U pytz
Not sure if it matters, but I don't have any shebangs in my python file.
Ended up moving my code from Sublime Text 3 over to PyCharm. This solved the issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.