简体   繁体   中英

Python script is running in Pycharm but not via bat file

I have a python script that is running OK in PyCharm. It's first line is 'import pandas'

I created a bat file that looks like this: "C:\Users\icohen1\AppData\Local\Microsoft\WindowsApps\python.exe" "C:\Users\MyName\PycharmProjects\pythonProject1\venv\LotsToTextFile.py" pause

When I run this bat file I get this error: import pandas ModuleNotFoundError: No module named 'pandas'

What am I missing here?

Thanks

I guess, the python environment you use in Pycharm is not C:\Users\icohen1\AppData\Local\Microsoft\WindowsApps\python.exe , but a virtual env Pycharm created for your project.

If you wish to run with the virtual env, go to Pycharm and find where the python.exe if virtual env is located, and modify your python path.

If you wish to run with "C:\Users\icohen1\AppData\Local\Microsoft\WindowsApps\python.exe" , you should install pandas for that global python.exe. Usually this will install it. in cmd shell

pip3 install pandas

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM