0

I want to create a command line with python (argparse). The goal is to import a dataframe and then print its 5 first rows, however, when I run the command, this error shows up :

File "try.py", line 3, in <module>
    import pandas as pd
  File "C:\Users\szouaoui\AppData\Local\Continuum\anaconda3\lib\site-packages\pandas\__init__.py", line 17, in <module>
    "Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy: DLL load failed: Le module spécifié est introuvable.

it seems that the program is unable to import the pandas library

here is the code:

import argparse
import sys
import pandas as pd
my_parser = argparse.ArgumentParser(description='Unconstraining demand for specified dates, shops and categories/n')
my_parser.add_argument("path",type=str, action="store")
my_args = my_parser.parse_args()

input_file = sys.argv[1]
data = pd.read_csv(input_file)
print(data.head())

command line :

python try.py /path_to_file/dataframe_name.csv
3
  • Try to execute your command line using the -m flag, without the .py extension: python -m try /path_to_file/dataframe_name.csv Commented Apr 14, 2020 at 20:23
  • The same erros showed up, but it works when I run the command on the anaconda prompt, maybe because pandas is installed on anaconda Commented Apr 14, 2020 at 20:45
  • Sure. Try to run in a conda environment then, or install pandas and all it's dependencies Commented Apr 14, 2020 at 20:47

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.