Python Forum
Why do i get these errors?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why do i get these errors?
#1
Hi I'm just a beginner programmer (13 yr old),
pls help!

So I was half-way through scripting the software, that saves student details in a csv file.
when I want to see the students details I just simply type search {Student name} and some details come related.
(Still need to be coded.)
I need help on,
Solving the errors.
Improving the script.
And how to make the body for this script.(Instead of running on the console, I need to change the appearance)


Heres the script
import csv
import os.path
import time
import imp
import sys

if not os.path.exists("D:\My folder\Projects\Programing\Python\Student Data storing app\Register.csv"):
   #run start up script
   print("Cache was Deleted!\nCreating new Cache")
   time.sleep(3)
   with open ("D:\My folder\Projects\Programing\Python\Student Data storing app\Register.csv", "w") as new_file :
       fieldnames = ["Full name", "Phone 1", "Phone 2", "Identity Number", "Email", "Paid/not"]
       csv_writer = csv.DictWriter(new_file, fieldnames = fieldnames, delimiter = ",")
       csv_writer.writeheader()

   file = open ("D:\My folder\Projects\Programing\Python\Student Data storing app\Data.txt", "w") #creates our file to say startup is complete you could write to this if you wanted as well
   def pass_new():
       password = input("Please enter a password.\nUse only letters.")
       pass_len = len(password)
       if pass_len < 10:
           print("Password saved!")
           file.write("Pass = " + password)
       else : print("Password must not exceed 10 characters.")
       sys.exit()


   pass_new()

   file.write()
   print("Startup is complete.")


   file.close

def pass_check():
    f = open("D:\My folder\Projects\Programing\Python\Student Data storing app\Data.txt")
    global data
    data = imp.load_source('data', '', f)
    f.close()
    correct_pass = data.Pass
    user_input_pass = input("Please enter your Password.")
    if user_input_pass == correct_pass:
        print("Password accepted!")
    else : print("Password incorrect.\nAccess denied!")
    sys.exit()

pass_check()
print("'add' - Adds a new user. \n'update' - Updates a user.")
print("'remove' - Removes a user.\n {confrim}")

user_input = input("Enter a command : ").lower()

if user_input == "add":
    print("Command - 'add'\n{Fullname} {Phone 1} {Phone 2} {Identity Number} {Email} {Paid/not}")
else : print("Error!\nPlease enter a valid option.")

if user_input == "update":
    print("Command - 'update'\n{Fullname} {Phone 1} {Phone 2} {Identity Number} {Email} {Paid/not}")
else : print("Error!\nPlease enter a valid option.")


if user_input == "remove":
    print("Command - 'remove'\n {Full name} {Identity number} ")
    confirm = input("Please 'Confirm' removal of user.\nThis cannot be undone! ~~~ (Type 'confirm')").lower()
    if confirm == "confrim":
        print("User removed")
    else : print("User not removed. :D")
else : print("Error!\nPlease enter a valid option.")
The errors!
Error:
D:\My folder\Projects\Programing\Python\Student Data storing app\Main.py:4: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses import imp Traceback (most recent call last): File "D:\My folder\Projects\Programing\Python\Student Data storing app\Main.py", line 47, in <module> pass_check() File "D:\My folder\Projects\Programing\Python\Student Data storing app\Main.py", line 38, in pass_check data = imp.load_source('data', '', f) File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\imp.py", line 171, in load_source module = _load(spec) File "<frozen importlib._bootstrap>", line 711, in _load File "<frozen importlib._bootstrap>", line 680, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 786, in exec_module File "<frozen importlib._bootstrap_external>", line 922, in get_code File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\imp.py", line 152, in get_data self.file = file = open(self.path, 'rb') FileNotFoundError: [Errno 2] No such file or directory: ''
I'm new to these forums, sorry If I didn't do this correctly.
Always happy to learn!
Reply


Messages In This Thread
Why do i get these errors? - by Oshadha - Dec-15-2020, 07:26 AM
RE: Why do i get these errors? - by buran - Dec-15-2020, 08:54 AM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 09:38 AM
RE: Why do i get these errors? - by buran - Dec-16-2020, 09:53 AM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 12:36 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 12:38 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 12:39 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 12:41 PM
RE: Why do i get these errors? - by buran - Dec-16-2020, 01:04 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 01:22 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 01:28 PM
RE: Why do i get these errors? - by buran - Dec-16-2020, 02:23 PM
RE: Why do i get these errors? - by Oshadha - Dec-16-2020, 02:56 PM
RE: Why do i get these errors? - by buran - Dec-16-2020, 03:07 PM
RE: Why do i get these errors? - by buran - Dec-16-2020, 03:12 PM
RE: Why do i get these errors? - by Oshadha - Dec-17-2020, 03:32 AM
RE: Why do i get these errors? - by ndc85430 - Dec-18-2020, 07:18 AM

Forum Jump:

User Panel Messages

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