I have a question about pex build. So we have this project structure and we are trying to build a pex file off of it. It has a WSDL file which needs to be referenced in the code. No matter what I do, when I run the pex file, it throws an exception: File Not Found . Does anyone have any idea how to fix it? I am fairly new to Python.
Below is the folder structure -
Main_Folder
Util
util1.py
main.py
WebService.xml
I tried this:
path = os.path.join(os.path.abspath(__file__), 'WebService.xml')
url = urllib.parse.urljoin('file:', urllib.request.pathname2url(os.path.abspath(path)))
Welcome to StackOverflow. As the error indicates, the path is not set correctly.
os.path.abspath(__file__)-> Gives you the absolute path of the file. If I run this code from a file named main.py I get the following output.C:\Users\User1\Desktop\main.pyExample of os.path.join
Outputs
/home/User/Public/Documents/-> As you can see it joins the directories.So you should now be able to see the problem you have. You path variable will hold something like this
C:\Users\User1\Desktop\main.py\WebService.xmlSo just change it to this `path = os.path.abspath('WebService.xml')
You can read more about the os module here