1.pycharm中windows找不到chrome解決辦法
打開pycharm–》File–》setting–》Tools–》Web Browsers 。然后添加chrome安裝路徑
2.inconsistent use of tabs and spaces in indentation
這個報錯就是混用了tab和4個空格造成的,檢查代碼,要不全部用tab,要不全部用4個空格,或者用idle編輯器校正
3.python中出現(xiàn)IndentationError:unindent does not match any outer indentation level錯誤
當前用的文本編輯器Notepad++,有個設(shè)置,可以顯示所有的字符的。
在: 視圖 –> 顯示符號 –> 顯示空格與制表符
這樣就可以看到我們Python代碼的到底有沒有該縮進的都縮進了。

4.# module 'pip' has no attribute 'main'
鏈接
找到安裝目錄下 helpers/packaging_tool.py文件,找到如下代碼:

修改:
def do_install(pkgs):
try:
try:
from pip._internal import main
except Exception as e:
from pip import main
except ImportError as e:
error_no_pip()
return main(['install'] + pkgs)
def do_uninstall(pkgs):
try:
#import pip
try:
from pip._internal import main
except Exception:
from pip import main
except ImportError:
error_no_pip()
return main(['uninstall', '-y'] + pkgs)
復(fù)制即可,自己打可能出現(xiàn)第2,3點問題
5.View function mapping is overwriting an existing endpoint function
定義了多個同名的視圖函數(shù),只需要改成不同的函數(shù)名即可。
6.Requirement already up-to-date: pip in d:\python_project\pyflaskdemovir\lib\site-packages (18.1)
pip更新及Requirement already up-to-date解決方法
7.Warning: (1366, "Incorrect string value: '\xD6\xD0\xB9\xFA\xB1\xEA...' for column 'VARIABLE_VALUE' at row 480")
暫時不影響功能
7.mysqlclient-1.3.13-cp34-cp34m-win_amd64.whl is not a supported wheel on this platform
原因是,下載的版本跟你的python版本不一致,如果你的pyhton 是64位3.7幾,就需要對應(yīng)下載cp37-amd64
下載地址
復(fù)制到你的虛擬環(huán)境下的D:\Python_project\Flask_shiyanlouenv\Scripts目錄下,用pip install 下載的文件名來解壓
eg:

8.Mysql忘記密碼
參考鏈接
我的操作步驟是,
1.檢查mysql的環(huán)境變量配置是否完全,不能在dos下使用mysql的話,查看安裝路徑并設(shè)置成環(huán)境變量。我是是
C:\Program Files\MySQL\MySQL Server 5.7\bin
你可以在mysql控制臺,show variables like "%char%";查看
參考
2.停止mysql的服務(wù) net stop mysql,如果停止失敗或者開啟失敗,可到任務(wù)管理器中去停止mysql服務(wù)
3.開啟一個cmd,執(zhí)行mysqld -nt --skip-grant-tables
4.在開啟一個cmd,執(zhí)行mysql -u root -p如果此時提示mysql不是內(nèi)部命令,說明你的環(huán)境變量沒安裝好.參考
5.進行第4步后,讓輸入密碼,直接按enter進入
6.修改密碼,依次執(zhí)行
第一步: use mysql
第二步: update user set password=password("new_pass") where user="root";// 'new_pass' 這里改為你要設(shè)置的密碼
第三步: flush privileges;
第四步:exit
最后重新打開mysql,輸入剛才設(shè)置的密碼就ok 了
其他資料參考默認密碼
8.UnicodeEncodeError: 'latin-1' codec can't encode characters in position 6-7: ordinal not in range(256)

9.Cannot add or update a child row: a foreign key constraint fails
刪除表,重新創(chuàng)建
10.解決IntelliJ IDEA中g(shù)it出現(xiàn)的 Could not read from remote repository問題
在Settings->Version Control->Git中,將SSH executable設(shè)置為Native即可,如圖,紅色方框中是要修改的地方。
鏈接
11.PermissionError: [Errno 13] Permission denied: 'D:\Python_project\Shiyanlou\file\courses.xlsx'
使用openpyxl進行文件保存時提示,原因是沒關(guān)閉文件。所有關(guān)閉你打開的文件就能正常保存啦
12.#flask from app import db ImportError: cannot import name ‘db’ 的解決方案
在app的init下,注冊了藍圖并且初始化數(shù)據(jù)庫的,在其他地方導入db,顯示導入錯誤。
app下的__init__.py中,db = SQLAlchemy() 位于blueprint之前
參考資料
13.Scrapy運行ImportError: No module named win32api錯誤
有些說下載對有https://github.com/mhammond/pywin32/releases,py32的版本,我的是下載了也不行,直接安裝了
pip install pypiwin32
14.SyntaxError: unexpected EOF while parsing
一般是最后一行括號沒補全,或者寫了for循環(huán)沒寫循環(huán)體,因為解釋器到底了度沒找到它要找到的東西
15.scrapy出現(xiàn):AttributeError: 'list' object has no attribute 'xpath'
for article in response.xpath('//div[@class="j-r-list"]/ul/li').extract()
應(yīng)該去掉extract()
16.Pychorm注冊碼
參考資料,使用第三步破解補丁激活,完美只需三步
17.在使用flask時,發(fā)現(xiàn)修改了路由,原來的還是能用,修改的找不到url,新增的路由也是
后面發(fā)現(xiàn)的原因可能是,運行了其他的項目,導致了端口的沖突,即使F5+ctrl強制清除緩存也不行。我重新關(guān)機,啟動,這下子就能行了。以后還是一個項目保持不同端口
18.Pycharm2018設(shè)置debug模式與host,port的坑
Additinal options欄 中:手動寫入 --host=127.0.0.2 --port=1234
19.

20.flask-mail提示AssertionError: No recipients have been added
原因,發(fā)送消息用send(message).使用send_message(message)就報錯了
20.Mysql顯示亂碼
在my.ini中設(shè)置了utf8,中文任然顯示亂碼,在mysql執(zhí)行查詢前,cmd默認編碼是GBK,而mysql默認使用的是utf-8 所以你可以設(shè)置cmd為gbk;,設(shè)置 set charset gbk;在進行查詢就能正常顯示了。
mysql命令窗口顯示亂碼怎么解決?

21.selenium.common.exceptions.WebDriverException: Message: unknown error: Element <a class="btn btn-default" onclick="SEARCH.page_jump(100,1)" href="javascript:;">...</a> is not clickable at point (884, 436). Other element would receive the click: <i class="tab-ico"></i>
使用selenium分頁時,提示,點擊事件被別的接收了
22.selenium.common.exceptions.WebDriverException: Message: 'phantomjs' executable needs to be in PATH.
在創(chuàng)建的時候,定義browser=webdriver.PhantomJS(executable_path=r'D:\phantomjs-2.1.1-windows\bin\phantomjs.exe')
23.UserWarning: Selenium support for PhantomJS has been deprecated, please use headless versions of Chrome or Firefox instead(warnings.warn('Selenium support for PhantomJS has been deprecated, please use headless '
Selenium 已經(jīng)棄用 PhantomJS ,請使用火狐或者谷歌無界面瀏覽器。
查找之后得到答案時selenium的版本問題,使用pip show selenium顯示默認安裝的是3.8.1版本
卸載之后重新pip install selenium==2.48.0安裝成功
24.Command "python setup.py egg_info" failed with error code 10 in C:\Users\ADMINI~1\AppData\Local\Temp\pip-install-fhgsebqh\pycurl\
win10下安裝pyspider出錯,到地址下載對應(yīng)的版本。復(fù)制到虛擬環(huán)境下的scripts中,進行pip install 安裝。參考:參考文件

在進行安裝pyspider就ok了
25.Target database is not up to date
出現(xiàn)這個原因是數(shù)據(jù)庫中的版本和 生成的版本不一致
我在偶然子刪除了versions,的所有.py文件,執(zhí)行migrate的時候,提示找不到05d75fbd0C2,py。說明最近的數(shù)據(jù)遷移用的是05d75fbd0C2.py的文件,日期是2018-11-15 1:14:59,我發(fā)現(xiàn)另外的e1818953642c.py的日期是11-15-21:21,時間是更晚的,根據(jù)該文的提示,刪除了 項目中刪除和數(shù)據(jù)庫中相同版本后面日期的版本的 .py 文件,即e1818953642c.py.然后在執(zhí)行

26.Can't locate revision identified by '57c816829403'
發(fā)現(xiàn)在兩臺電腦來回切換的話,容易出現(xiàn)25的問題,比如在公司一臺,回家一臺,在某一臺更新了數(shù)據(jù)庫,在另外一臺還是以前的版本,所以運行遷移的時候,就會報25,或者26的錯誤?,F(xiàn)在是,直接刪除


重新
python manage.py db initpython manage.py db migratepython manage.py db upgrade這樣子數(shù)據(jù)不會丟失.
27. pychorm使用vue,提示# Uncaught ReferenceError: Vue is not defined 當出現(xiàn)這個問題的原因及處理
把vue.js放在頂部參考
28.No application found. Either work inside a view function or push an application context.
from simpledu.app import create_app
app=create_app("development")
app.app_context().push()
29.Python提示object is not subscriptable的錯誤
subscriptable的意思是 可有下標的 意思
錯誤的原因就是把不具有下標操作的對象用成了對象[i],比如int對象變量[i]就會報錯。仔細檢查錯誤行。
30TypeError: get() takes no keyword arguments
字典get方法,get("a",default="b")報錯,不寫default,直接寫get("a","b")
30,semantic ui 圖標不能正常加載
參考
復(fù)制 解壓包中的fonts以及images到項目的static下,修改成 .. /fonts.參考資料中的就行
31.django在關(guān)閉debug后,靜態(tài)文件無法加載的解決辦法
32.django.db.migrations.exceptions.MigrationSchemaMissing: Unable to create the django_migrations table ((1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1"))
mysql不支持5.5了
Ubuntu安裝MySQL及遇到的問題解決方案
unbuntu下mysql升級,問題相關(guān)
參考資料
Can 't connect to local MySQL server through socket '/tmp/mysql.sock '(2)
mysql升級相關(guān)
34,Django jwt 自定義登錄錯誤
參考資料
1.安裝該文檔對照修改,
https://github.com/GetBlimp/django-rest-framework-jwt/pull/317/commits/c3a4c3fc5180473a92a94af07613463b2bc2b325?diff=split
修改好之后就能提供該功能
settings.py中設(shè)置
JWT_AUTH = {
'JWT_EXPIRATION_DELTA': datetime.timedelta(days=7),
'JWT_AUTH_HEADER_PREFIX': 'JWT',
'JWT_RESPONSE_PAYLOAD_HANDLER': 'app_news.api.jwt_response_payload_handler',
'JWT_RESPONSE_PAYLOAD_ERROR_HANDLER': 'app_news.api.jwt_response_payload_error_handler',
}
注意:app_news.api這個根據(jù)你的路徑修改。
api.py中設(shè)置方法,方法里自己設(shè)置想要的結(jié)構(gòu)把
def jwt_response_payload_handler(token, user=None, request=None):
return {
‘token’: token,
‘user’: UserSerializer(user, context={‘request’: request}).data
}
def jwt_response_payload_error_handler(serializer, request=None):
return {
'status': 200,
'message': "用戶名或者密碼錯誤",
'data': None
}
35.Django django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet
原因是我想寫了個腳本,運行腳本提示了這個。解決辦法
第一步,在urls,中設(shè)置
import os,django
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "xxxx.settings")
django.setup()
第二步腳本中設(shè)置
要使用model,需要提前導入urls
import AI_News.urls
from app_news.models import NewsTag
36 導入項目執(zhí)行 run manage.py task 報錯找不到xx.settings
注意你導入的項目的,django項目目錄位置,一定根項目導入