5

Python : 3.5

IDE : Visual code

Platform : win 10 64 bit

First i created a virtual env _kerasVenv and then activated the env and then installed pandas using pip.

This is my directory structure:

enter image description here

I added a python script in Exercise files folder where I am trying to read .csv file using pandas

test= pd.read_csv('test.csv', encoding='utf-8')

.csv file and python script are in the same folder so wrong path is not the issue.But i am getting below error:

Unable to open 'parsers.pyx': Unable to read file (Error: File not found (c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps\pandas\_libs\parsers.pyx)).

Can someone explain why python is looking for pandas in c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps folder and why parsers.pyx file does not exist in original pandas folder which are in _kerasVenv folder? How can i get rid of this error?

Update: I found out while hovering on import pandas as pd statement that it is looking for pandas module in c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps . Why it is happening?

desertnaut
  • 57,590
  • 26
  • 140
  • 166
Anudocs
  • 686
  • 1
  • 13
  • 54

2 Answers2

1

I think it is easier to always give the total file path.

Instead of:

test= pd.read_csv('test.csv', encoding='utf-8')

try to use:

test = pd.read_csv('C:/users/anubhav.jhalani/downloads/ex_files_building_deep_learning_apps/test.csv', endcoding='utf-8')

this should help, you can also have a look here, what syntax you need to write it: Windows path in Python

You can also get the full path in your windows explorer, if you are unsure where it is saved.

PV8
  • 5,799
  • 7
  • 43
  • 87
  • Tried but still same error. I found out while hovering on 'import pandas as pd' statement that it is looking for pandas module in 'c:\users\anubhav.jhalani\downloads\ex_files_building_deep_learning_apps' . It is weird to me. why it is happening? – Anudocs Sep 18 '19 at 10:45
  • thats an different error then, you need to install pandas in this enviorment! – PV8 Sep 18 '19 at 10:46
  • it is already installed in the virtual env '_kerasVenv' and I am using this env in vscode. – Anudocs Sep 18 '19 at 10:47
  • did oyu check it: https://stackoverflow.com/questions/15961926/how-can-i-make-a-list-of-installed-packages-in-a-certain-virtualenv – PV8 Sep 18 '19 at 10:48
  • 1
    well. I didnt understand the problem but reinstalling pandas and giving complete path of the file(even if file is in the same folder) fixes the problem. – Anudocs Sep 18 '19 at 11:31
0

In my case it also wasn't able to find the file even in the same directory and with the complete path. I figured it out that this issue was happening only in my VSCode editor and when I opened the same notebook in jupyter lab it was perfectly working. So then I tried one thing that make it work for me in VSCode as well was that I put my file in the directory other than "C". For example I put my file in the "D" directory and in VSCode it becomes able to work fine.

Feroz Khan
  • 2,396
  • 5
  • 20
  • 37