簡體   English   中英

代碼在 VS Code 中運行,但不在終端中

[英]Code is running in VS Code but not in Terminal

我的 python 腳本在 vs 代碼中完美運行,但是當我通過終端運行它時,我收到錯誤消息“ImportError: No module named concurrent.futures”

我使用 venv 和 pip 列表顯示:

   Package        Version   
-------------- ----------
appdirs        1.4.4     
attrs          19.3.0    
beautifulsoup4 4.9.1     
black          19.10b0   
certifi        2020.4.5.2
chardet        3.0.4     
click          7.1.2     
futures        3.1.1     
idna           2.9       
pathspec       0.8.0     
pip            19.2.3    
regex          2020.6.8  
requests       2.23.0    
setuptools     41.2.0    
soupsieve      2.0.1     
toml           0.10.1    
typed-ast      1.4.1     
urllib3        1.25.9  

我的代碼中的導入如下所示:

import concurrent.futures
import csv
import os
import re
import time
from datetime import date
import requests
from bs4 import BeautifulSoup

我也試過:

  • from futures import ThreadPoolExecutor
  • import concurrent.futures
  • 安裝不在 venv 中的期貨
  • 更新期貨
  • 卸載期貨

編輯:我的目標是每天運行腳本,所以我按照這個教程鏈接,我被困在我創建 Unix 可執行文件的點上。 當我運行此文件時,終端會顯示錯誤。

我自己弄清楚了,這很簡單......

在教程中,他們創建了這個文件

#!/bin/sh
Python /Users/yanissilloul/Documents/instabot-master/examples/like_hashtags_copy.py neonphotography

解決方案是在運行 .py 文件之前激活 venv。

#!/bin/sh
source .venv/bin/activate
Python /Users/yanissilloul/Documents/instabot-master/examples/like_hashtags_copy.py neonphotography

感謝 Niklas Mertsch,你的問題把我帶到了那里。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM