0

I am new to Python so bear with me.

I have recently download the pdblp module in a zip form. I then made some amendments that were needed to get through specific requests. So I have this folder, is there a way where I normally write Import pdblp that I can write import 'F:\Sam\project\' as pdblp or should it not be done like this?

Timbus Calin
  • 13,809
  • 5
  • 41
  • 59
Sam Harper
  • 61
  • 1
  • 3
  • 10
  • to import it you need it on your path, so either run from that dir or dump it in you /lib/site-packages or add it to your PYTHONPATH – Nullman Dec 23 '19 at 13:36
  • Check the [docs](https://docs.python.org/3/reference/import.html#regular-packages). – xiaoyu2006 Dec 23 '19 at 13:37

2 Answers2

1

You can import folder as package not module. *.py file is itself module. If you want to import folder, you need add init.py file inside the folder and then it will become package then you can import

0

Assuming that the module pdblp is located inside your project-directory, you can simple append your current path and then import it afterwards like so:

import sys
# Keep in mind that you need to escape backslashes by doubling them
sys.path.append("F:\\Sam\\project\\")

import pdblp
Razorfen
  • 423
  • 4
  • 12
  • 1
    `# Keep in mind that you need to escape backslashes by doubling them` Actually you can use [`'C:/Sam/project'`](https://stackoverflow.com/a/2953843/10811334). – xiaoyu2006 Dec 23 '19 at 13:41