perform python Script , Prompt error :/usr/bin/python^M: Interpreter error : There is no file or directory
This mistake , For just used linux function python Script people have encountered , Or run something else Windows Write good code , There is no way to start this problem if you don't understand it , Only go online for help . It's also a good thing , It's also quite a sense of achievement to find the answer and solve it by yourself .
vi filename.py
:set ff perhaps :set fileformat
fileformat=dos or fileformat=unix
# dos Express windows System
# unix Express Unix System ,linux Also belong to class Unix System
:set ff=unix or :set fileformat=unix
# Check again whether the format has changed
:set ff
:wq
Save and exit , Run script We are using pip install python Packet time , The following errors often occur :
ERROR: Could not find a version that satisfies the requirement xxxx(from versions: none)
ERROR: No matching distribution found for xxxx
The main problems are pip The source of the problem
Directly choose pip Source and trust its source can solve this problem .
Below, Douban source is used , Replace it with Qinghuayuan 、 Aliyuan is applicable .
pip install Library package name -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
pip Some mirror addresses in China :
Alibaba cloud http://mirrors.aliyun.com/pypi/simple/
University of science and technology of China https://pypi.mirrors.ustc.edu.cn/simple/
douban (douban) http://pypi.douban.com/simple/
Tsinghua University https://pypi.tuna.tsinghua.edu.cn/simple/
Chinese academy of sciences http://pypi.mirrors.opencas.cn/simple/
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
cd /root
mkdir .pip
vi pip.conf
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com
Be careful :
http://mirrors.aliyun.com/pypi/simple/
Medium simple Directory must have .trusted-host = mirrors.aliyun.com
Be sure to add this line , Otherwise, an error will be reported .