代码在 VS 代码中是 运行 但在终端中不是
Code is running in VS Code but not in Terminal
我的 python 脚本在 vs 代码中完全 运行ning,但是当我通过终端 运行 它时,我收到错误消息
"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 中安装 futures
- 更新期货
- 卸载期货
编辑:
我的目标是每天 运行 该脚本,所以我遵循了本教程 Link
我一直停留在创建 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,你的问题让我想到了这里。
我的 python 脚本在 vs 代码中完全 运行ning,但是当我通过终端 运行 它时,我收到错误消息 "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 中安装 futures
- 更新期货
- 卸载期货
编辑: 我的目标是每天 运行 该脚本,所以我遵循了本教程 Link 我一直停留在创建 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,你的问题让我想到了这里。