欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

關(guān)于vscode?默認(rèn)添加python項(xiàng)目的源目錄路徑到執(zhí)行環(huán)境的問(wèn)題

 更新時(shí)間:2022年02月21日 08:33:12   作者:包子鋪1234  
這篇文章主要介紹了vscode?默認(rèn)添加python項(xiàng)目的源目錄路徑到執(zhí)行環(huán)境,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

背景

在vscode剛剛裝好的時(shí)候,對(duì)于開(kāi)發(fā)人員來(lái)說(shuō)可能需要寫(xiě)一些模塊的測(cè)試,而這個(gè)模塊可能又引用了其他模塊,

如果是同級(jí)目錄的話可能會(huì)出現(xiàn)ModuleNotFoundError: No module named 錯(cuò)誤

圖文件結(jié)構(gòu)和代碼所示,ddd.py文件和ccc.py文件 分別在test1和test2目錄下,ccc.py文件需要調(diào)用ddd.py文件的函數(shù)。

原因:

在test2的ccc.py文件中執(zhí)行print(sys.path) 查看路徑

['g:\\go_code\\first_demo\\test2',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32\\lib',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\Pythonwin']

返回結(jié)果發(fā)現(xiàn)并無(wú)g:\\go_code\\first_demo\\ 的路徑,所以test2下面的文件引用不到test1下面的文件屬于正常

解決方案:

在setting.json文件中加入

"terminal.integrated.env.osx": {
    "PYTHONPATH": "${workspaceFolder}/",
},
"terminal.integrated.env.linux": {
    "PYTHONPATH": "${workspaceFolder}/",
},
"terminal.integrated.env.windows": {
    "PYTHONPATH": "${workspaceFolder}/",
},

然后重啟vscode,再次test2的ccc.py文件中執(zhí)行print(sys.path) 查看路徑

['g:\\go_code\\first_demo\\test2',
'G:\\go_code\\first_demo',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\win32\\lib',
'D:\\Users\\Administrator\\AppData\\Local\\Programs\\Python\\Python310\\lib\\site-packages\\Pythonwin']

發(fā)現(xiàn)多了項(xiàng)目的源目錄路徑。

接著執(zhí)行ccc.py模塊發(fā)現(xiàn)可以正常運(yùn)行了。

參考文章:

https://www.qualityology.com/tech/marking-a-folder-as-sources-root-equivalent-in-visual-studio-code-for-python/

到此這篇關(guān)于vscode 默認(rèn)添加python項(xiàng)目的源目錄路徑到執(zhí)行環(huán)境的文章就介紹到這了,更多相關(guān)vscode python項(xiàng)目目錄路徑內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python使用Pillow實(shí)現(xiàn)圖像基本變化

    Python使用Pillow實(shí)現(xiàn)圖像基本變化

    這篇文章主要為大家詳細(xì)介紹了Python如何使用Pillow實(shí)現(xiàn)圖像的基本變化處理,文中的示例代碼講解詳細(xì),具有一定的學(xué)習(xí)價(jià)值,需要的可以了解一下
    2022-10-10
  • python抓取并保存html頁(yè)面時(shí)亂碼問(wèn)題的解決方法

    python抓取并保存html頁(yè)面時(shí)亂碼問(wèn)題的解決方法

    這篇文章主要介紹了python抓取并保存html頁(yè)面時(shí)亂碼問(wèn)題的解決方法,結(jié)合實(shí)例形式分析了Python頁(yè)面抓取過(guò)程中亂碼出現(xiàn)的原因與相應(yīng)的解決方法,需要的朋友可以參考下
    2016-07-07
  • Python實(shí)現(xiàn)刪除重復(fù)視頻文件的方法詳解

    Python實(shí)現(xiàn)刪除重復(fù)視頻文件的方法詳解

    這篇文章主要為大家詳細(xì)介紹了如何利用Python實(shí)現(xiàn)刪除重復(fù)視頻文件功能,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Python有一定幫助,需要的可以參考一下
    2022-10-10
  • python實(shí)現(xiàn)登錄與注冊(cè)功能

    python實(shí)現(xiàn)登錄與注冊(cè)功能

    這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)登錄與注冊(cè)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-01-01
  • Python特效之?dāng)?shù)字成像方法詳解

    Python特效之?dāng)?shù)字成像方法詳解

    所謂數(shù)字成像,即將原圖片經(jīng)過(guò)python處理后,生成完全由純數(shù)字組成的圖像。本文將具體為大家介紹一下這一效果如何實(shí)現(xiàn),需要的可以參考一下
    2022-01-01
  • 關(guān)于如何使用python的gradio庫(kù)

    關(guān)于如何使用python的gradio庫(kù)

    這篇文章主要介紹了關(guān)于如何使用python的gradio庫(kù),Gradio是一個(gè)功能豐富的Python庫(kù),可以讓您輕松創(chuàng)建和共享自己的交互式機(jī)器學(xué)習(xí)和深度學(xué)習(xí)模型,需要的朋友可以參考下
    2023-04-04
  • python腳本生成caffe train_list.txt的方法

    python腳本生成caffe train_list.txt的方法

    下面小編就為大家分享一篇python腳本生成caffe train_list.txt的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2018-04-04
  • python 在threading中如何處理主進(jìn)程和子線程的關(guān)系

    python 在threading中如何處理主進(jìn)程和子線程的關(guān)系

    這篇文章主要介紹了python 在threading中如何處理主進(jìn)程和子線程的關(guān)系,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-04-04
  • Python使用Matplotlib繪制3D圣誕樹(shù)

    Python使用Matplotlib繪制3D圣誕樹(shù)

    這篇文章主要為大家詳細(xì)介紹了Python如何使用Matplotlib繪制3D圣誕樹(shù),文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2023-12-12
  • 教你用Type Hint提高Python程序開(kāi)發(fā)效率

    教你用Type Hint提高Python程序開(kāi)發(fā)效率

    本文通過(guò)介紹和實(shí)例教大家如何利用Type Hint來(lái)提升Python程序開(kāi)發(fā)效率,對(duì)大家使用python開(kāi)發(fā)很有幫助,有需要的參考學(xué)習(xí)。
    2016-08-08

最新評(píng)論