ValueError: source code string cannot contain null bytes when importing a package in python

80 views Asked by At
from pyModbusTCP.client import ModbusClient

I am using pycharm and I have a class file which uses methods from pyModbusTCP package to communicate with devices over modbus. This class files exists as part of a directory in my project, where under the project folder I have a folder for device1 containing that particular class file along with some others. The idea was to simply duplicate the folder and title it device2, the intent being device2 functions as a backup to device1.

I created a device2 folder, made a main.py and copied most of the other contents from device1. The console is giving me only the error from the title at line 1, meaning the very first import statement that I linked is the cause for me receiving the error from the title. Given all that I have no idea what the error is even referring to, could anyone help me troubleshoot? Thanks!

EDIT:

Traceback (most recent call last):
  File "/home/env1/Simulation/main.py", line 11, in <module>
    import read_from_modbus
  File "/home/env1/Simulation/read_from_modbus.py", line 1, in <module>
    from pyModbusTCP.client import ModbusClient
ValueError: source code string cannot contain null bytes

0

There are 0 answers