exercism / support

Please use https://github.com/exercism/exercism for opening support issues.
3 stars 3 forks source link

python/hello-world: problems downloading and solving the exercise #102

Open P-Loaf opened 3 years ago

P-Loaf commented 3 years ago
NobbZ commented 3 years ago

Hi @P-Loaf, it seems as if you forgot to submit some text with your issue, can you please elaborate on your problem?

Please include the track you are working on in the description and what you have tried so far and what the error is, if there is any.

P-Loaf commented 3 years ago

I am working on the Python track. I downloaded the exercise using "exercism download --exercise=hello-world --track=python" and the terminal says its downloaded to \Exercism\python\hello-world. When I type "C:\Users\ploaf>exercism open" it says "Error: accepts 1 arg(s), received 0". I went through windows and there's nothing in the exercism file.

NobbZ commented 3 years ago

Can you please show the output of dir C:\Exercism\pythopn\hello-world?

If you see any output that is not an error message, than the download worked as expected.

Please use any editor you like to open the python files in that folder. Also use cd in the terminal to navigate to that location and run the tests as described in the tracks documentation.

P-Loaf commented 3 years ago

it says "Downloaded to C:\Users\ploaf\Exercism\python\hello-world after I downloaded it but then I plug in what you

C:\Users\ploaf>dir C:\Exercism\pythopn\hello-world? The system cannot find the file specified.

NobbZ commented 3 years ago

The system cannot find the file specified.

Yes, because the download location is different from what you originally said.

Please try dir C:\Users\ploaf\Exercism\python\hello-world instead.

P-Loaf commented 3 years ago

06/15/2021 03:13 PM

. 06/15/2021 03:13 PM .. 06/15/2021 03:13 PM .exercism 06/17/2021 03:10 PM 22 hello_world.py 06/17/2021 03:10 PM 285 hello_world_test.py 06/17/2021 03:10 PM 2,305 README.md 3 File(s) 2,612 bytes 3 Dir(s) 898,139,168,768 bytes free

On Thu, Jun 17, 2021 at 3:27 PM Norbert Melzer @.***> wrote:

The system cannot find the file specified.

Yes, because the download location is different from what you originally said.

Please try dir C:\Users\ploaf\Exercism\python\hello-world instead.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/exercism/cli/issues/997#issuecomment-863506350, or unsubscribe https://github.com/notifications/unsubscribe-auth/AUQFWIYW3ZIETXX34QVYZULTTJED3ANCNFSM46ZRYERA .

NobbZ commented 3 years ago

This looks as if the exercise has been downloaded succesfully. Please use your favorite editor to open the hello_world.py and write your solution in it. Run the tests in that folder as described in the tracks documentation, or perhaps in the README even.

P-Loaf commented 3 years ago

Thanks for your help!

P-Loaf commented 3 years ago

I guess Exercism was installed on the C: drive but also under users. I was able to find the file, make the program and save it. Now when I run the tests using pytest it says... ================================================ no tests ran in 0.00s ================================================ ERROR: file or directory not found: hello-world.py

Also, when I copy the submit thing from the website and put in the directory it says its not there. Any idea whats going on with this?

NobbZ commented 3 years ago

The program is usually installed to C:\Exercism if I recall correctly, though the "workspace" the folder to which the exercises are downloaded to is in the users "home" folder, or however it is called in windows speak.

How are you running the pytest?

NobbZ commented 3 years ago

Also: \cc @exercism/python

BethanyG commented 3 years ago

Hi 👋🏽 @P-Loaf -- Python mentor/maintainer here. 😄 As @NobbZ said, it would be great if we could see how you are running/calling pytest, and which directory you are doing that from. It appears that pytest is not able to collect the tests in the hello_world_test.py file, because it cannot find/navigate to the C:\Users\ploaf\Exercism\python\hello-world directory -- which is where those tests are kept.

Try running pytest hello_world_test.py from C:\Users\ploaf\Exercism\python\hello-world (navigate to the directory on the cmd line, and once you are there run pytest) and see if that helps.

P-Loaf commented 3 years ago

@BethanyG , @NobbZ was right, the program is in C:\ Exercism and the "workspace" is under "users" - but no particular user. I used the command to naviage to the directory and got this:

C:\users\exercism\python\hello-world Volume in drive C is OS Volume Serial Number is 24A6-4513

Directory of C:\users\exercism\python\hello-world

06/18/2021 01:27 PM

. 06/18/2021 01:27 PM .. 06/15/2021 03:13 PM .exercism 06/18/2021 01:11 PM 21 hello_world.py 06/18/2021 01:00 PM 285 hello_world_test.py 06/18/2021 01:27 PM 2,305 README.md 06/22/2021 07:49 AM pycache 3 File(s) 2,611 bytes 4 Dir(s) 896,176,152,576 bytes free

Then ran Pytest and got this: C:\Users\ploaf>pytest hello_world_test.py ================================================= test session starts ================================================= platform win32 -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: C:\Users\ploaf collected 0 items

================================================ no tests ran in 0.03s ================================================ ERROR: file or directory not found: hello_world_test.py

NobbZ commented 3 years ago

You need to run pytest from within the exercises folder, so in your case it would be C:\users\exercism\python\hello-world.

P-Loaf commented 3 years ago

this is what I got when I ran that:

C:\Users\Exercism\python\hello-world>pytest hello_world_test.py ================================================= test session starts ================================================= platform win32 -- Python 3.9.5, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 rootdir: C:\Users\Exercism\python\hello-world collected 0 items / 1 error

======================================================= ERRORS ======================================================== ____ ERROR collecting hello_worldtest.py ____ ImportError while importing test module 'C:\Users\Exercism\python\hello-world\hello_world_test.py'. Hint: make sure your test modules/packages have valid Python names. Traceback: c:\users\ploaf\appdata\local\programs\python\python39\lib\importlib__init__.py:127: in import_module return _bootstrap._gcd_import(name[level:], package, level) hello_world_test.py:3: in from hello_world import hello E ImportError: cannot import name 'hello' from 'hello_world' (C:\Users\Exercism\python\hello-world\hello_world.py) --------------------------------------------------- Captured stdout --------------------------------------------------- Hello World =============================================== short test summary info =============================================== ERROR hello_world_test.py !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ================================================== 1 error in 0.48s ===================================================

C:\Users\Exercism\python\hello-world>

BethanyG commented 3 years ago

@P-Loaf -- what does the content of your hello_world.py file look like? It appears from the PyTest error message that the tests inside hello_world_test.py are looking for a function named hello inside the hello_world.py file, but that function name doesn't exist. Something like this should be in that hello_world.py file:

def hello():
    pass

....with pass replaced by the code that completes the exercise. If the function is not named hello, the import part of the test run will fail.

khoivan88 commented 3 years ago

@P-Loaf, seems like hello_world_test.py could not find the function hello in your hello_world.py file! How does your hello_world.py content look like?

Update: should have known @BethanyG is on it already! You are in good hand, @P-loaf!

BethanyG commented 3 years ago

It's actually @NobbZ we should be thanking....he's the one that figured out the Windows install directories! 😄 But thank you @khoivan88 for jumping in as well. We're smarter together.

khoivan88 commented 3 years ago

you are too kind @BethanyG . Yes, @NobbZ discovery of the weird installation issue is great. I would never have thought of that. I was thinking that the structure of the tests folder and perhaps you would have to call python -m pytest instead of just pytest but it does not make sense seeing the test file and the python files are in the same folder. It has been a while since I am looking at these exercises!

P-Loaf commented 3 years ago

Thanks for your help on all of this. I'm just getting my beak wet with python but im trying to learn! I had it as print("Hello World") but I can see why that wont work.

khoivan88 commented 3 years ago

@P-Loaf : no worry at all, 😄 . We all started at some point. I was taking my first computer programming course online almost 4 years ago!!

P-Loaf commented 3 years ago

What course did you take? Its like information overload trying to find the right one.

BethanyG commented 3 years ago

There are waaaay too many courses! I think my favorite are these from EdX -- but they're very "collegy", and not necessarily for everyone. But I very much enjoyed the problem sets and projects.

edit -- the fee is for a certificate, BTW ... the courses are actually free through EdX.

khoivan88 commented 3 years ago

What course did you take? Its like information overload trying to find the right one.

Oh gosh, I think my very first was something like 'Intro to C#' or something. It was pretty easy but I think I didn't really remember much after that. I think only when I took the Harvard CS50 (https://www.edx.org/course/introduction-computer-science-harvardx-cs50x?hs-referral=course-listing), everything is finally clicked. That course was very challenging yet was pretty much my springboard! After that, I follow this curriculum loosely: https://github.com/ossu/computer-science. I still came back to the CS50 series with Web and Machine Learning. Planning in the future for Mobile App development!

I second what @BethanyG said, I really like EdX, I took free courses there all the time. Fun fact, I have not paid for any of the online programming courses (I think it is more than 10 courses or something now). I couldn't afford them!

BethanyG commented 3 years ago

Oooh, YES @khoivan88 -- CS50 from Harvard is excellent. There is a whole series now, if I remember.... Harvard CS courses EdX. I am a big ole EdX fangirl. 😉 . Fun fact: The Open EdX platform is OSS, built on Django and Python, and open for contributors.... right here on GitHub 😄 https://github.com/edx/edx-platform

khoivan88 commented 3 years ago

Oooh, YES @khoivan88 -- CS50 from Harvard is excellent. There is a whole series now, if I remember.... Harvard CS courses EdX. I am a big ole EdX fangirl. 😉 . Fun fact: The Open EdX platform is OSS, built on Django and Python, and open for contributors.... right here on GitHub 😄 https://github.com/edx/edx-platform

Count me in, I am a huge fan of CS50 series and Edx!!!! CS50 series is so challenging yet really helped to give you a big boost! Lol, I do need to finish that CS50 Web to familiarize myself more with Django. Web development has not come natural to me. I feel so lost with its huge number of knowledge, HTML, CSS, Javascript, piled on top of hundreds of frameworks and on different programming languages too. I have been struggling so much with it even though I am doing more of web development these days!

BethanyG commented 3 years ago

@P-Loaf -- Two more resources, if working through written material is more your thing:

  1. David Beazley's Python Course. This one is geared to someone who already has some programming under their belt, but is new to Python. David Beazley's talks are also awesome.
  2. Quick Python by Naomi Ceder. Naomi is the chair of the PSF, and an excellent teacher. This is a paid resource, but might also be available through libraries.

edit: I would get yelled at if I didn't also put down Automate the Boring Stuff With Python. Al Sweigart is a good teacher. It is also a paid resource, and now has a sequel -- but there is also a CC-licensed older version free on the web. He also has a Udemy course, and the first 15 lessons are free on YouTube.

khoivan88 commented 3 years ago

@P-Loaf -- Two more resources, if working through written material is more your thing:

David Beazley's Python Course. This one is geared to someone who already has some programming under their belt, but is new to Python. David Beazley's talks are also awesome. Quick Python by Naomi Ceder. Naomi is the chair of the PSF, and an excellent teacher. This is a paid resource, but might also be available through libraries.

Me: quickly bookmarking these sources!!!

Fun fact, it was you, @BethanyG who taught me about the existence of Generator Comprehension

khoivan88 commented 3 years ago

@P-Loaf , with the risk of overloading you, I am so sorry. I really like this book too. Very practical, and the author already published the sequel: https://automatetheboringstuff.com/

Free! (yay) This was the one that really got me started with Python in practical daily things. CS50 basic focuses a lot on the basic foundation (which is very useful) but only touches Python for like 2 or 3 lectures!

BethanyG commented 3 years ago

@khoivan88 -- see my edit above (giggle). Great minds..... 😆

Fun fact, it was you, @BethanyG who taught me about the existence of Generator Comprehension

Happy I could do that! Favor to ask? Wanna write a V3 concept exercise about them?? #jokingnotjoking

BethanyG commented 3 years ago

ok....we'd better leave you alone @P-Loaf ... so we don't scare you away! But please do let us know if you run into any further issues, or have any further questions!

khoivan88 commented 3 years ago

@khoivan88 -- see my edit above (giggle). Great minds..... 😆

Fun fact, it was you, @BethanyG who taught me about the existence of Generator Comprehension

Happy I could do that! Favor to ask? Wanna write a V3 concept exercise about them?? #jokingnotjoking

Loll, I know, we like the same stuff! Although, only you are great, I am just mere mortal and scraping by with my below average code quality!

I would love to try if I could find some time right now but I have just got into freelancing and it is exhausting trying to get new clients/works on Upwork! Basically, the whole reason why I stopped mentoring and could not contribute to v3. :(. So sorry, @BethanyG!!!

P-Loaf commented 3 years ago

Thank you for the references I will check all of them out. I tried Code with Mosh but it didn't really have any practical exercises so I returned it. I've heard Automate the Boring Stuff has a good Udemy course. think I should try it?

khoivan88 commented 3 years ago

@P-Loaf: I heard about Code with Mosh and was wondering about it. I saw that he has a lot of courses.

About 'Automate the Boring Stuff', I have never took the Udemy course, I just followed the free CC online book and follow his examples as well as doing the exercises. Definitely some good stuff there!

P-Loaf commented 3 years ago

@khoivan88 I did Mosh's 1-hr and 6-hr Python courses which were free and I liked them so I bought the complete package. After I got about halfway through I stopped and returned it because it was more of a fast-paced lecture with really no opportunity for me to apply anything. It seemed like he was just showing stuff off that someone at my skill level wouldn't remember. I'm just searching for something that I can practice as I go along so it sinks in. I know alot of people like his courses, though.

khoivan88 commented 3 years ago

@P-Loaf : that is great info to know about the Mosh's courses. Yeah, I am the same type where I need to practice and practice in order to remember anything. THat is why I like 'Automate the Boring stuff' a lot. Too bad that CS50 series does not have any Python focus (at least I don't think so), otherwise it would have been a good alternative too. All of the CS50 courses I took, they always have the homework and they are so challenging but really help you learn a lot of stuff!

P-Loaf commented 3 years ago

@khoivan88 thanks again, I will check all these references out. I found Automate the Boring Stuff on PDF so I will read that and take it from there. Cheers

P-Loaf commented 3 years ago

Hey sorry to bother you guys but can you help me submit this thing? I passed the test but im getting errors like:

C:\Users\Exercism\python\hello-world>exercism submit /C:\Users\Exercism\python\hello-world\hello_world.py Error: CreateFile C:\C:\Users\Exercism\python\hello-world\hello_world.py: The filename, directory name, or volume label syntax is incorrect.

P-Loaf commented 3 years ago

I tried this:

C:\Users\Exercism\python\hello-world>exercism submit hello_world.py Error: CreateFile C:\Users\ploaf\Exercism: The system cannot find the file specified.

NobbZ commented 3 years ago

Either use a valid absolut path (similar to your first try, but without the leading slash) or use a correct relative path (similar to your second try, but either cd into the correct location first or adjust the path to actually point to the exercises file, relative to your working dir).

P-Loaf commented 3 years ago

what would I put in differently? it seems like im there in the command prompt and its just not finding the file

khoivan88 commented 3 years ago

@P-Loaf : assuming in your terminal, you are currently in this folder, I assume this is where your hello_world.py is: C:\Users\Exercism\python\hello-world, then you can try this:

exercism submit "C:\Users\Exercism\python\hello-world\hello_world.py"