单机测试python编写的mapper时出现/usr/bin/python3^M: bad interpreter: No such file or directory

在单机测试python编写的mapper时出现

hadoop@ub1401:~/hadoop/hadoopfile$ cat keywords-blank-1.txt|./PictureDownloadMapper.py
bash: ./PictureDownloadMapper.py: /usr/bin/python3^M: bad interpreter: No such file or directory

经查有可能是

1、执行权限的问题

2、python版本的问题

3、python文件格式的错误。

权限问题利用chmod +x ***py即可

版本问题,在执行时或者在py文件中选择好python的版本

格式问题参考博文,解决过程如下:

hadoop@ub1401:~/hadoop/hadoopfile$ vi PictureDownloadMapper.py

在vi编辑器下:

:set ff 或 :set fileformat

可以查看到当前的格式(fileformat=dos 或 fileformat=unix

修改格式为unix

:set ff=unix或者 :set fileformat=unix

:wq保存退出



你可能感兴趣的:(大数据,hadoop,python)