[英]Visual Studio Code Python Configuration Error
最近我開始和其他人一起做一個項目。 該項目的一部分是在 Python 上制作的,當我嘗試執行它時,我收到以下錯誤:
File "D:\projects\company\spiders\country\spain\cities\runnables\short.py", line 22, in <module>
soup = get_soup_from_url(url, "html.parser")
NameError: name 'get_soup_from_url' is not defined
在與我的一些合作伙伴交談后,看起來我是唯一遇到此錯誤的人,該代碼適用於除我之外的其他所有人。 我想這是我的 Visual Studio Code 的一個問題,因為我們都使用編輯器和 Windows 10。
我做了一個小而簡單的項目,我在兩個小腳本中遇到了同樣的錯誤,項目遵循以下結構:
- spiders
- country
- spain
- cities
- runnable
- short.py
- utils
- driver.py
腳本如下:
簡短的.py
import sys
sys.path.append('../../../../utils')
from driver import *
print_on_console('Hello world!')
驅動程序.py
def print_on_console(message):
print(message)
所以基本上我在嘗試將 function "print_on_console" 導入 short.py 時收到此錯誤。
我不知道是否有必要,但這是我的設置。json 來自 Visual Studio 代碼:
{
"terminal.integrated.tabs.enabled": true,
"security.workspace.trust.untrustedFiles": "open",
"editor.fontSize": 18,
"workbench.colorTheme": "Oceanic Next (dimmed bg)",
"tabnine.experimentalAutoImports": true,
"editor.guides.bracketPairs": true,
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"terminal.integrated.profiles.windows": {
"PowerShell": {
"source": "PowerShell",
"icon": "terminal-powershell"
},
"Command Prompt": {
"path": [
"${env:windir}\\Sysnative\\cmd.exe",
"${env:windir}\\System32\\cmd.exe"
],
"args": [],
"icon": "terminal-cmd"
},
"Git Bash": {
"source": "Git Bash"
},
"Ubuntu-20.04 (WSL)": {
"path": "C:\\Windows\\System32\\wsl.exe",
"args": ["-d", "Ubuntu-20.04"]
},
"Ubuntu (WSL)": {
"path": "C:\\Windows\\System32\\wsl.exe",
"args": ["-d", "Ubuntu"]
}
},
"terminal.integrated.defaultProfile.windows": "PowerShell"
}
作為擴展,我目前使用的與 Python 相關的是:
提前感謝任何試圖幫助我解決這個問題的人!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.