2

I have a simple python script including pandas which I want to run using powershell using python "C:\Users\...\Test script.py". However, running the script in powershell results in the following error message:

+ python "test_function.py"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (Traceback (most recent call last)::String) [], 
RemoteException
+ FullyQualifiedErrorId : NativeCommandError

File "test_function.py", line 1, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'

The python script runs normally in pycharm and when I delete the part where using the pandas the script also runs via powershell. Hence, my question is how to run a python script with pandas using powershell?

bml
  • 115
  • 7
  • 2
    How did you install Python? If you're using conda you probably need to activate the `base` environment first. You're `pandas` installation is probably in the virtual environment and the interpreter you're calling can't find it – Alessandro Gaballo Jan 15 '20 at 15:07
  • similar question in this page, check if that helps https://stackoverflow.com/questions/19676403/running-python-in-powershell – KApril Jan 15 '20 at 15:11
  • @AlessandroGaballo I indeed use conda to install python. Do you mean to activate `base` in powershell first? Any idea how to do that? – bml Jan 15 '20 at 15:18
  • @bml `conda activate base` should do the job, if the conda executable is in your path – Alessandro Gaballo Jan 15 '20 at 15:28
  • @AlessandroGaballo could you maybe elaborate a bit more on "if the conda executable is in your path"? Thanks in advance! – bml Jan 15 '20 at 15:35
  • @bml have a look at this: https://stackoverflow.com/questions/47800794/how-to-activate-different-anaconda-environment-from-powershell/54811138 – Alessandro Gaballo Jan 15 '20 at 15:52
  • 1
    Great it works! Thanks you so much! – bml Jan 15 '20 at 15:59

0 Answers0