Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install csv package in pycharm

I have a problem with installing csv package in pycharm (running under python 3.5.2)

When I try to install it I get an error saying

Executed command: pip install --user csv

Error occurred: Non-zero exit code (1)

Could not find a version that satisfies the requirement csv (from versions: ) No matching distribution found for csv

I updated the pip package to version 9.0.1 but still nothing.

When I run the following code:

import csv
f = open('fl.csv')
csv_f = csv.reader(f)
f.close()

I get this error:

csv_f = csv.reader(f) AttributeError: module 'csv' has no attribute 'reader'

I thought it was because I could not install the "csv package"

also I tried running:

import csv
print(dir(csv))

and the print result is:

['doc', 'loader', 'name', 'package', 'path', 'spec']

A lot of methods including csv.reader are missing

This is pretty much all the useful information up until comment #29

like image 265
criticalth Avatar asked Dec 09 '16 13:12

criticalth


People also ask

How install csv file in PyCharm?

Right-click inside a delimited text file and then click Edit as Table. Also, you can click the Edit as Table icon in the editor. In the dialog that opens, specify format settings and click OK. The dialog has two predefined formats (CSV and TSV) and lets you create a custom format.

How do I install PyCharm modules?

Expand the list of the available versions in the upper-right corner of the tool window. Select the required version or keep it the latest. Click the Install button next to the version list. Once PyCharm notifies you about successful installation, you should see the package in the list of the installed packages.


3 Answers

for python 3, you should run this command:

pip install python-csv
like image 55
Mehrnoosh Nobakht Avatar answered Sep 17 '22 19:09

Mehrnoosh Nobakht


You can't pip install csv because the csv module is included in the Python installation.

You can directly use :

import csv

in your program

Thanks

like image 22
Venkataraman K S Avatar answered Oct 12 '22 19:10

Venkataraman K S


  1. 'csv' is an in-built package. So you dont have to install it again in Pycharm.
  2. When you try to import csv, make sure that you dont have any file(created by you) named as 'csv.py' in your project folder(or Python Path Variable folders) because of this you are not actually importing 'csv' package.
like image 4
jestadi Avatar answered Oct 12 '22 17:10

jestadi