I'm making a LINE bot that scrapes with Python.
An error has occurred in the import of BeautifulSoup, and it cannot be resolved.
After examining various things, I think that the installed Python is different from the installed part, but as long as I examine it myself, it seems to match.
I would appreciate it if you could tell me the cause and how to investigate.
Windows10, the execution environment is heroku.
heroku logsshows the following log.
2019-11-19T15: 35: 15.021825 + 00: 00 app [web.1]: sys.version_info (major = 3, minor = 7, micro = 4, releaselevel = 'final', serial = 0) 2019-11-19T15: 35: 15.022294 + 00: 00 app [web.1]: Traceback (most recent call last): 2019-11-19T15: 35: 15.022301 + 00: 00 app [web.1]: File "main.py", line 16, in<module> 2019-11-19T15: 35: 15.022528 + 00: 00 app [web.1]: import scrape as sc 2019-11-19T15: 35: 15.022534 + 00: 00 app [web.1]: File "/app/scrape.py", line 4, in<module> 2019-11-19T15: 35: 15.022708 + 00: 00 app [web.1]: from bs4 import BeautifulSoup 2019-11-19T15: 35: 15.022762 + 00: 00 app [web.1]: ModuleNotFoundError: No module named 'bs4'
The import part of scrape.py is written as follows.
# for debugging import sys print (sys.version_info) import urllib.request from bs4 import BeautifulSoup import json import requests
- Install BeautifulSoup
pip install beautifulsoupis executed, the following is displayed.
I understand that the installation is complete.
Requirement already satisfied: beautifulsoup4 in c: \ pg \ python \ lib \ site-packages (4.8.1) Requirement already satisfied: soupsieve>= 1.2 in c: \ pg \ python \ lib \ site-packages (from beautifulsoup4) (1.9.5)
There is certainly a bs4 folder under C: \ pg \ Python \ Lib \ site-packages.
I don't know where heroku's Python says it can't be found.
Change environment variables
The system environment variable was changed and restarted as follows, but there was no change.
PYTHONPATH C: \ pg \ Python \ Lib \ site-packages
Check reference path in interactive mode
Execution command and execution result in interactive mode.
>>>import sys >>>print (sys.path) ['', 'C: \\ pg \\ Python \\ Lib \\ site-packages',' C: \\ pg \\ Python \\ python37.zip ',' C: \\ pg \\ Python \\ DLLs', 'C: \\ pg \\ Python \\ lib', 'C: \\ pg \\ Python']
- Try various other commands
I tried it while referring to https://www.tutorialfor.com/go.php?id=64929 ,
I did not understand the cause well.
python -c "import bs4"⇒ Nothing special
Thank you. .
Please let me know if there is any missing information.
Answer # 1
Do you have
If you do not have this when deploying to heroku, the necessary modules will not be installed.
It seems to be misunderstood, but deploying to heroku means running the program in a completely different environment from the one you are currently developing.
- python - regular expression: sub () cannot replace the matched part
- [python] cannot insert or delete to text box
- python - firebase_admin cannot be imported
- python - all commands cannot be used with discord bot
- i cannot transition from the sbi securities home screen to the futures trading screen by scraping python + selenium
- python image display error beginner, thank you
- python - cannot inherit a class with multiple arguments
- python - discord bot command cannot be started
- python - idle cannot resolve the "rootgeometry" error
- python - ephem module cannot be imported in vscode
- python - mnist cannot be imported
- python - the csv file cannot be displayed
- cannot read python dat file
- python - elements cannot be acquired after screen transition in selenium
- python 3x - xg boost cannot be installed from anaconda prompt
- python - mysqlclient cannot be installed on centos7
- python - cannot convert csv file to excel file (contents are not copied )
- python - image cannot be read by opencv
- python - tfkerasapplication model cannot be downloaded
- python : PyAutoGui is not installed
- Can't install anything with PIP (python)
- Unable to download scipy for python to raspberry pi
- Error in Pip installation: "python setup.py egg_info" failed with error code 1
- python : "Pyinstaller" is not an internal or external command, executable program or batch file
- How to install python-levenshtein correctly
- python : Error installing pyinstaller via pip
- python : Why is kivy not installing?
- python : Problem installing pytelegrambotapi module
- python : Error while deploying "git push heroku master"