Python Forum
Can anyone help me successfully run this code?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can anyone help me successfully run this code?
#1
Sad 
OK, so I'm a TOTAL newbie to Python, & I hope this is the only time I will ever have to use it! But in any case, this is my dilemma...

(Oh, an important note: I fear that listing the whole input codes for every article will make the post difficult to read, so if any of you would like screencaps of the code inputs & results instead, please let me know.)

To begin, I am running Python 3.11 on Windows 10. I wish to execute the Python 3.11 program in CMD Prompt so that I may run my .py file "the-great-suspender-restore-urls", which will help to, well, restore the broken Great Suspender links in my saved Chrome session (named tabs.json) by changing them all back to their actual URLs. (There's another list of broken links I want to restore, but the same answers will apply, so it's redundant & not in need of posting.) The commands I need to run this Python script are as follows:

C:\Users>cd Desktop\the-great-suspender-restore-urls-0.4

C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>python thegreatsuspender.py

restore-the-great-suspender-urls --in-file=tabs.json --out-file=tabs-restored.json
As I have been directed by another Python user, I have both the G.S.R.U. Python script & the Tabs JSON file(s) that needs fixing in the same folder (which is highlighted in blue in the picture below). After that, I changed the Path user variable by putting the link to the aforementioned folder as its value. I also changed the Path system variable value to the folder where my Python program is (highlighted in faint gray).

[Image: EIXQP.png]

So, it seems like everything should work out perfectly from this point on, right? WRONG! For as soon as I told CMD Prompt to do the second & third of the three commands listed above, I got this instead:

C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>python thegreatsuspender.py
usage: thegreatsuspender.py [-h] --in-file IN_FILE --out-file OUT_FILE [--session-name-suffix SESSION_NAME_SUFFIX]
                            [--extension-id EXTENSION_ID] [--verbose]
Error:
thegreatsuspender.py: error: the following arguments are required: --in-file, --out-file
C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>restore-the-great-suspender-urls --in-file=tabs.json --out-file=tabs-restored.json
Error:
'restore-the-great-suspender-urls' is not recognized as an internal or external command, operable program or batch file.
So, how am I supposed to overcome THIS hurdle? All I wanna do is just run this freaking Python script to restore my broken Great Suspender URLS:

restore-the-great-suspender-urls --in-file=tabs.json --out-file=tabs-restored.json
I've been trying to accomplish this task for over a month, & I'm really getting frustrated & desperate. :-(

---

Additional attempts I've made thus far:

Attempt 1: I tried saying in respective order:

python restore-the-great-suspender-urls --in-file=tabs.json --out-file=tabs-restored.json

python restore-the-great-suspender-urls --in-file=./tabs.json --out-file=./tabs-restored.json
Outcome: I got this message instead.

Error:
C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4> python restore-the-great-suspender-urls --in-file=./tabs.json --out-file=./tabs-restored.json python: can't open file C:\\Users\\User\\Desktop\\the-great-suspender-restore-urls-0.4\\restore-the-great-suspender-urls': [Errno 2] No such file or directory
Attempt 2: Added the .py extension to the name of the script I wanted to run, but got almost the exact same message as above.

Attempt 3: Simply typed in "restore-the-great-suspender-urls.py". That only gave me this output:
Error:
The system cannot find the file specified.
OK, just so we're on the up & up: I linked environmental variable paths to the respective locations of my Python program & the Python script I want to run to restore my broken Great Suspender URLs. I can get Python itself to be recognized & used by Command Prompt, but any commands involving my Great Suspender Restore URLs are totally bust.

Attempt 4: I checked the (first) tabs.json file & G.S.R.U. Python script, & both were spelled correctly. Nothing still happened.

Attempt 5: I tried to navigate to the directory via CMD, run "dir", & post the output. This is the output I got:

Error:
Directory of C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4 05/20/2023 10:28 AM <DIR> . ///// 05/20/2023 10:28 AM <DIR> .. ///// 02/09/2021 06:22 PM 833 CHANGELOG.rst ///// 02/04/2021 05:04 PM 1,073 LICENSE ///// 02/04/2021 07:26 PM 107 MANIFEST.in ///// 02/09/2021 06:31 PM 6,306 PKG-INFO 02/09/2021 06:26 PM 4,082 README.rst ///// 02/09/2021 06:31 PM 53 setup.cfg ///// 02/09/2021 06:21 PM 1,810 setup.py ///// 04/07/2023 01:46 PM 4,048,672 tabs.json ///// 02/09/2021 06:31 PM 40,960 the-great-suspender-restore-urls-0.4.tar ///// 02/09/2021 06:21 PM 5,978 thegreatsuspender.py ///// 05/20/2023 10:28 AM <DIR> the_great_suspender_restore_urls.egg-info
Attempt 6: I checked to see if PIP was installed, & if the G.R.S.U. Python package was also installed. Both were positive! ^_^ All I had to do then, was navigate to the Desktop directory with my tabs JSON file(s) & GRSU script, & run the command:

C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4> python thegreatsuspender.py
usage: thegreatsuspender.py [-h] --in-file IN_FILE --out-file OUT_FILE [--session-name-suffix SESSION_NAME_SUFFIX]
                            [--extension-id EXTENSION_ID] [--verbose]
Still didn't work. Result was this:

Error:
python thegreatsuspender.py: error: the following arguments are required: --in-file, --out-file
Attempt 7: Apparently, the problem with the last attempt was that I was running the command one at a time, instead of as a part of the application. So just running --in-file for instance, had no effect, because the system knows nothing about a command named --in-file. What I needed to do was run the following command, all in one line, in the directory where my tabs JSON files were:

restore-the-great-suspender-urls --in-file=tabs.json --out-file=tabs-restored.json
Then came this problem:

İmage


Attempt 8: The application threw the previous error, because it was basically trying to parse the data in a way that it couldn't. Thus, at an acquaintance's suggestion, I tried converting the tabs JSON file first in Notepad++, changing the encoding style from UTF-8-BOM to UTF. I saved, closed, & reopened the tabs JSON file to check if its encoding had successfully converted. Upon seeing that it did, I copied & pasted the new tabs JSON file into my tabs directory. Then, with a little help from Google, I found & subsequently saved all of the right input codes I needed to finally run the command! ^_^

The initial input codes:
restore-the-great-suspender-urls \
    --in-file=tabs.json \
    --out-file=tabs-restored.json \
    --extension-id='ahmkjjgdligadogjedmnogbpbcpofeeo' \
    --verbose
The input codes formatted for CMD:
usage: thegreatsuspender.py [-restore-the-great-suspender-urls] --in-file=tabs.json --out-file=tabs-restored.json [--session-name-suffix=' - FIXED']
                            [ --extension-id='ahmkjjgdligadogjedmnogbpbcpofeeo'] [--verbose]
With that, I put the final codes into CMD...& then came this freaking problem!

C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>	--in-file=tabs.json \
Error:
'--in-file' is not recognized as an internal or external command, operable program or batch file.
C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>	--out-file=tabs-restored.json \
Error:
'--out-file' is not recognized as an internal or external command, operable program or batch file.
C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>	--extension-id='ahmkjjgdligadogjedmnogbpbcpofeeo' \
Error:
'--extension-id' is not recognized as an internal or external command, operable program or batch file.
C:\Users\User\Desktop\the-great-suspender-restore-urls-0.4>	--verbose
Error:
'--verbose' is not recognized as an internal or external command, operable program or batch file.
Attempt 9: I typed in the input codes all in one line, & that also failed.

And that's where I'm stuck right now. So, I need to know the proper answers to the following questions:
1. What exactly am I doing wrong? What mistakes did I make, if any?
2. What are the complete steps I should take in order to get the code to finally run?
3. How exactly should I format the final code in CMD?

Please, please help me out! I don't wanna have to keep trying & failing to restore my broken tab URLs ad nauseum... :-(
Reply


Messages In This Thread
Can anyone help me successfully run this code? - by TheMouseAvenger - Jun-19-2023, 08:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  how do I successfully use PDO with my ODBC for MSSQL? cyberion1985 3 6,769 Jun-26-2018, 04:44 PM
Last Post: Maverick494
  Cannot successfully install NumPy aniketmone2017 3 7,513 Dec-29-2016, 02:14 PM
Last Post: sparkz_alot

Forum Jump:

User Panel Messages

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