-1

My python script is perfectly running in vs code, but when I run it via terminal I get the error message "ImportError: No module named concurrent.futures"

I use a venv and a pip list shows:

   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  

The import in my code looks like this:

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

I also tried:

  • from futures import ThreadPoolExecutor
  • import concurrent.futures
  • installing futures not in a venv
  • updating futures
  • uninstalling futures

EDIT: my goal is to run the script daily so I followed this tutorial Link and I'm stuck at the point were I create a Unix executable file. When I run this file the terminal shows the error.

GePlusE
  • 13
  • 10
  • are you sure you have activated your virtual environment before running your code? – Kumar Sanu Jun 09 '20 at 20:31
  • my goal is to run the script daily so I followed a tutorial (link in post) and I'm stuck at the point were I create a Unix executable file. When I run this file the terminal shows the error. (edited my original post with this) – GePlusE Jun 09 '20 at 20:39
  • What did you type in the terminal and what happened then? Error messages are often indicative of the problem – Niklas Mertsch Jun 09 '20 at 21:11
  • My script works fine in vs code. I followed the tutorial and created an unix file so I can start the script by clicking the file. When clicking the unix file terminal shows a Traceback and " import concurrent.futures ImportError: No module named concurrent.futures" – GePlusE Jun 09 '20 at 21:29
  • thanks @NiklasMertsch for this question it brought me to the solution. – GePlusE Jun 10 '20 at 14:49

1 Answers1

0

I figured it out my self and it was quite simple...

In the tutorial they create this file with

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

The solution was to activate the venv before running the .py file.

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

Thanks to Niklas Mertsch, your question brought me there.

GePlusE
  • 13
  • 10