MongoClient does not connect on python executable

I have my mongodb data on mongo.db.net and it works fine when I run the program from pycharm IDE.

client = MongoClient("mongodb+srv://Mongo-User:xxx@xxx.o1dff.mongodb.net/mydatabase?retryWrites=true&w=majority")

When I create the executable with pyinstaller, mongo tables do not load and the following error appears when I build with --debug: "Attribute Error: ‘NonType’ object has no attribute ‘Write’ \n "

I tried creating executable through cx_Freeze as well. I have the same problem. The error I get is as follows "AttributeError: ‘GenericRdata’ object has no attribute 'target.

Appreciate if anyone could help

Hi @Irshad_Wahab

I’m not familiar with mongo.db.net hosting and we recommend using MongoDB Atlas, specifically the free tier, for this course.

I’d suggest using Atlas and letting us know if you still encounter this issue.

Kindest regards,
Eoin

Thank you Eoin,

I am using MongoDB Atlas but the data is on cloud.mongodb.com. I am using the cloud hosting for the data for portability of my application.

Appreciate your assistance!

Hi @Irshad_Wahab

I’m glad to hear you are using MongoDB Atlas and it definitely provides the maximum portability for MongoDB databases in cloud hosting.

Can you expand on the specific connection that is occurring and which lesson/lab this is happening to you in?

In terms of pyinstaller, we don’t use this for the course and if you have questions around this or cx_Freeze, I’d suggest you try asking the question in the ODM/Drivers project but as neither are MongoDB supported tools you might also need to ask in the forums for those tools. I don’t have experience in either so I’m afraid I don’t have any suggestions beyond asking others who would be better placed to answer on those third-party libraries/tools.

Kindest regards,
Eoin

Thank you Eoin! Appreciate your suggestions!!

Thanks @Irshad_Wahab, I’ll close out this thread and let you continue the discussions in the other topics.

If you have any M220P questions or issues with the course, feel free to open a new ticket and we’ll be delighted to help you.

Kindest regards,
Eoin