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 - watchdog is installed, but i get the error modulenotfounderror: no module named'watchdog'
- python - psycopg2 cannot pip install
- python 3x - sentence classification keras cannot build a model from embedding to lstm well
- [python 390 idle] idle cannot be started
- python - filename cannot be assigned to a variable when using a for statement with a shell command in google colaboratory
- i can't make screen transitions in python (i'm a real beginner)
- python 3x - the error when moving a folder cannot be resolved
- cannot post html form on local web server using python
- python - opencv videocapture cannot be used
- python seleniun error modulenotfounderror: no module named'selenium'
- python 3x - cannot write file when python3 csv file is open
- \ r \ n cannot be deleted with python
- image recognition using python beginner pyautogui is not possible
- python - pyhthon-folium cannot be colored when creating a choropleth diagram
- python - $pip install -r requirementstxt cannot be executed with an error
- cannot use replace () in python sympy library
- python - 'tuple' object has no attribute'dot' cannot be resolved
- python - self-made module appapp cannot be imported
- [python] [tkinter] the exe file created by pyinstaller cannot be executed
- cannot combine python pdf files (multiple processing using excel list and for statement)
- python - i can't push to heroku
- python - pip install git doesn't work
- i can't use pip with python
- python - please tell me the solution of gunicorn: command not found when deploying heroku (crying)
- about how to eliminate the error when updating python with raspbian (buster)
- python - i want to save a database on heroku by creating a discord bot, but i don't understand how to handle heroku redis
- python - [ubuntu20041] pip version does not go up
- python - blueqat cannot be installed
- python - the library installed by pip cannot be imported no module named'selenium'
- python importerror i want to resolve