Python Forum
Cannot Make the python Code work
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cannot Make the python Code work
#1
Here is a post I already put on another forum. I am not sure if it posted so I am running it again.

I am having trouble making the following code work :

check this link:

https://www.youtube.com/watch?v=tE1aYQ-EgJ0&t=3s

The requirements.txt file is now shown here:

numpy==1.18.0

requests==2.22.0

beautifulsoup4==4.8.2

pygame==1.9.6

The program fails on the initial import statements which are now shown:

import numpy as np

from fractions import Fraction

from webscraping.website import CWebsite

from util.message import message

import util.utilities as ut

from templates.HTML_template_elements import make_html

Now I ran the requirements.txt file ike so

pip install -r requirments.txt

It gave me no errors. I assumed that would take care of all the import statements. It did not.

This program runs on python 2.7.15. But when I ran the requirements.txt file

and then ran

either pip list

or

conda list

BeautifulSoup did not show up.

I have no idea why it did not show up.

As I said it fails on the import statements.

I am running it on Ubuntu 18.04 and it should work.

It the youtube video he ran it on Windows 10 with the Anaconda prompt, not the DOS/Windows prompt.

Should that make any difference?

As i said i ran it on Ubuntu 18.04 in Jupyter notebook.

I do not know how t correct the import errors.

Any help appreciated. Thanks in advance.

R,

Newport_j
Reply
#2
I have always had trouble on this forum. I am not sure what is wrong with this code posting. Posting any kind of graphic is hard on this forum; likewise attaching files.

I can use the code box if you want. Anyway, just tell me what you want and I will give it to you.

How do I attach files? That is a hard one.

Respectfully,

Newport_J
Reply
#3
(Apr-21-2020, 12:43 PM)ErnestTBass Wrote: How do I attach files? That is a hard one.
How to attach a file
There are also easy solution on web eg GE.TT

The YouTube link is a little sketchy for my taste Easy RISK FREE $£$£ using FREE Software
Quote:This program runs on python 2.7.15. But when I ran the requirements.txt file
You should be using Python 2 anymore.
Reply
#4
I am not using Python 2.7 code. The person who wrote this program is.

I just want the program to run. When I get that I will move it to Python 3.8 or whatever
is the latest version of python.

As I said before the requirements.txt file and the import module section at the top of the source
code look completely unrelated. They should be strongly connected.

I am curious as to how you determined the Python version this code requires to run. You said something about requirements.txt
file, but I do not see how it determines the version of Python. I know how to create a requirements.txt
file. I just do not see it telling me the python version to use on the code.

Respectfully,

ErnestTBass
Reply
#5
(Apr-23-2020, 12:40 PM)ErnestTBass Wrote: am not using Python 2.7 code. The person who wrote this program is.

I just want the program to run. When I get that I will move it to Python 3.8 or whatever
is the latest version of python.

Repo link in in Youtube.
As we did talk about conda in other Thread i will use that.
So i use pip(will pull down Python 3.8.2) here as conda can't find Pygame.

Here are all commands,and it works for me.
# Make enviroment
G:\Anaconda3\Scripts
λ conda create --name scraper_env pip
Collecting package ....

# Activate
G:\Anaconda3\Scripts
λ activate scraper_env

# Cd to enviroment
(scraper_env) G:\Anaconda3\Scripts
λ cd ..

(scraper_env) G:\Anaconda3
λ cd envs\

(scraper_env) G:\Anaconda3\envs
λ cd scraper_env\

# Clone Repo
(scraper_env) G:\Anaconda3\envs\scraper_env
λ git clone https://github.com/SpiceBucks/SpicyArbs.git
Cloning into 'SpicyArbs'...
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 33 (delta 10), reused 30 (delta 7), pack-reused 0
Unpacking objects: 100% (33/33), done.
Checking connectivity... done.

# Navigate
(scraper_env) G:\Anaconda3\envs\scraper_env
λ cd SpicyArbs\

# list files dir(in cmd)
(scraper_env) G:\Anaconda3\envs\scraper_env\SpicyArbs (master)
λ ls
LICENSE  README.md  main_webscraper.py  requirements.txt  templates/  util/  webscraping/

# Use requirements.txt
(scraper_env) G:\Anaconda3\envs\scraper_env\SpicyArbs (master)
λ pip install -r requirements.txt
Collecting ....
Successfully installed beautifulsoup4-4.8.2 chardet-3.0.4 idna-2.8 numpy-1.18.0 pygame-1.9.6 requests-2.22.0 soupsieve-2.0 urllib3-1.25.9

# Run code
(scraper_env) G:\Anaconda3\envs\scraper_env\SpicyArbs (master)
λ python main_webscraper.py
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
DEBUG::Examining American Football arbitrage opportunities.
DEBUG::Examining arbitrage opportunities in game: BYU at Utah.
DEBUG::Considering market: Winner.
DEBUG::Examining arbitrage opportunities in game: USC at Alabama.
DEBUG::Considering market: Winner.
DEBUG::Examining arbitrage opportunities in game: Michigan at Washington Huskies.
DEBUG::Considering market: Winner.
DEBUG::Examining arbitrage opportunities in game: Louisville at Clemson.
DEBUG::Considering market: Winner.
DEBUG::Examining arbitrage opportunities in game: Ohio State at Oregon.
DEBUG::Considering market: Winner.
......
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  hi need help to make this code work correctly atulkul1985 5 772 Nov-20-2023, 04:38 PM
Last Post: deanhystad
  newbie question - can't make code work tronic72 2 675 Oct-22-2023, 09:08 PM
Last Post: tronic72
  Cleaning my code to make it more efficient BSDevo 13 1,357 Sep-27-2023, 10:39 PM
Last Post: BSDevo
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,321 May-22-2023, 10:39 PM
Last Post: ICanIBB
  Beginner: Code not work when longer list raiviscoding 2 816 May-19-2023, 11:19 AM
Last Post: deanhystad
  how to make bot that sends instagram auto password reset code kraixx 2 1,361 Mar-04-2023, 09:59 PM
Last Post: jefsummers
  Why doesn't this code work? What is wrong with path? Melcu54 7 1,775 Jan-29-2023, 06:24 PM
Last Post: Melcu54
  Code used to work 100%, now sometimes works! muzicman0 5 1,427 Jan-13-2023, 05:09 PM
Last Post: muzicman0
  color code doesn't work harryvl 1 883 Dec-29-2022, 08:59 PM
Last Post: deanhystad
  Make code non-blocking? Extra 0 1,130 Dec-03-2022, 10:07 PM
Last Post: Extra

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020