[英]install csv package in pycharm
I have a problem with installing csv package in pycharm (running under python 3.5.2)我在pycharm中安装csv包时遇到问题(在python 3.5.2下运行)
When I try to install it I get an error saying当我尝试安装它时,我收到一条错误消息
Executed command: pip install --user csv
执行命令:
pip install --user csv
Error occurred: Non-zero exit code (1)发生错误:非零退出代码 (1)
Could not find a version that satisfies the requirement csv (from versions: ) No matching distribution found for csv找不到满足 csv 要求的版本(来自版本:)找不到与 csv 匹配的发行版
I updated the pip package to version 9.0.1 but still nothing.我将 pip 包更新到 9.0.1 版,但仍然没有。
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' csv_f = csv.reader(f) AttributeError: 模块 'csv' 没有属性 'reader'
I thought it was because I could not install the "csv package"我以为是因为我无法安装“csv包”
also I tried running:我也试过运行:
import csv
print(dir(csv))
and the print result is:打印结果是:
[' doc ', ' loader ', ' name ', ' package ', ' path ', ' spec '] [' doc ',' loader ',' name ',' package ',' path ',' spec ']
A lot of methods including csv.reader are missing缺少包括 csv.reader 在内的很多方法
This is pretty much all the useful information up until comment #29这几乎是所有有用的信息,直到评论 #29
You can't pip install csv
because the csv module is included in the Python installation.您不能
pip install csv
因为 csv 模块包含在 Python 安装中。
You can directly use :您可以直接使用:
import csv
in your program在你的程序中
Thanks谢谢
The problem is that you have another file in your directory called csv.py
.问题是您的目录中有另一个名为
csv.py
文件。 And in this file you do not have a reader
function.在这个文件中你没有
reader
功能。
Change its name to my_csv.py
将其名称更改为
my_csv.py
对于 python 3,你应该运行这个命令:
pip install python-csv
您应该转到 PyCharm 中的终端并输入:
pip3 install python-csv
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.