Python Forum
Error on import: SyntaxError: source code string cannot contain null bytes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error on import: SyntaxError: source code string cannot contain null bytes
#4
Okay in the interest of full disclosure my Python session looks like this:

Python 3.11.4 (tags/v3.11.4:d2340ef, Jun  7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append("C:\\Users\\kirkw\\Documents\\Python")
>>> sys.path
['', 'C:\\Users\\kirkw\\AppData\\Local\\Programs\\Python\\Python311\\python311.zip', 'C:\\Users\\kirkw\\AppData\\Local\\Programs\\Python\\Python311\\DLLs', 'C:\\Users\\kirkw\\AppData\\Local\\Programs\\Python\\Python311\\Lib', 'C:\\Users\\kirkw\\AppData\\Local\\Programs\\Python\\Python311', 'C:\\Users\\kirkw\\AppData\\Local\\Programs\\Python\\Python311\\Lib\\site-packages', 'C:\\Users\\kirkw\\Documents\\Python']
>>> import fibo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
SyntaxError: source code string cannot contain null bytes
>>> import kirk
>>> kirk.fib(1000)
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987
>>>
I previously created the file fibo.py and then saved it as kirk.py. fibo, as indicated in the session notes above, causes the interface to throw the indicated message. This is not stopping me from moving on in my learning process. However, nuisances like this have a tendency to bite you later on when building production code.

TIA
Larz60+ write Aug-01-2023, 10:40 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply


Messages In This Thread
RE: Error on import: SyntaxError: source code string cannot contain null bytes - by kirkwilliams2049 - Aug-01-2023, 05:16 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  delivery exe without source code py loky62 2 412 Apr-04-2024, 05:47 PM
Last Post: loky62
  Algorithm for extracting comments from Python source code Pavel1982 6 680 Feb-28-2024, 09:52 PM
Last Post: Pavel1982
  How to express null value klatlap 3 910 Mar-25-2023, 10:40 AM
Last Post: klatlap
  import module error tantony 5 3,586 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Cryptic Error with import statement Led_Zeppelin 2 2,617 Jan-11-2022, 01:13 PM
Last Post: Led_Zeppelin
  Install any library via pip get an error cannot import name 'SCHEME_KEYS' from 'pip. Anldra12 2 10,808 Jan-04-2022, 01:05 PM
Last Post: Anldra12
  value null when update in json file 3lnyn0 6 3,463 Dec-30-2021, 05:52 PM
Last Post: ndc85430
  No Module found in other directory than source code [SOLVED] AlphaInc 1 2,124 Nov-10-2021, 04:34 PM
Last Post: AlphaInc
  Generating classes diagram from source code Pavel_47 3 5,811 Oct-01-2021, 03:31 AM
Last Post: Lou
  How do I open the Source code of a library? JaneTan 1 2,330 Aug-18-2021, 02:12 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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