程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

-Bash usrbinpython3^m the bad interpreter doesnt have that file or directory

編輯:Python

-bash: /usr/bin/python3^M: Bad interpreter : There is no file or directory

【1】 Problem phenomenon

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 .

【2】 Cause analysis

  • Generally, this kind of problem , It's a coding problem ,Windows The coding format is the same as linux The encoding format of is wrong .
  • Most of it is because the script file is in windows Edited by .
  • stay Windows in , The end of each line is \r\n, And in the linux The end of the next file is \n.

【3】 Problem solving

  • Open file , View encoding format
vi filename.py
:set ff perhaps :set fileformat
  • Format information :
fileformat=dos or fileformat=unix
# dos Express windows System 
# unix Express Unix System ,linux Also belong to class Unix System 
  • Modify the format :
:set ff=unix or :set fileformat=unix
# Check again whether the format has changed 
:set ff
  • :wq Save and exit , Run script

Python The installation package reported an error ERROR: Could not find a version that satisfies the requirement XXX resolvent

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/

windows And linux Permanent modification in the environment pip How to mirror the source

1、 stay windows Modify in environment pip How to mirror the source

  • stay windows File manager , Input %APPDATA%
  • Will navigate to a new directory , Create a new pip Folder , And then to pip Create a new one in the folder pip.ini file
  • In the new pip.ini Enter the following in the file
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com

2、 stay linux Update in the system pip How to source

  • Create a directory named .pip Folder
cd /root
mkdir .pip
  • After creating the .pip Create a folder named pip.conf The file of
vi pip.conf
  • stay pip.conf Enter the following in the file
[global]
timeout = 6000
index-url = http://pypi.douban.com/simple
trusted-host = pypi.douban.com

Be careful :

  1. http://mirrors.aliyun.com/pypi/simple/ Medium simple Directory must have .
  2. trusted-host = mirrors.aliyun.com Be sure to add this line , Otherwise, an error will be reported .

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved