Home > Enterprise >  How to use another python project function into your project
How to use another python project function into your project

Time:01-28

I'm working with Django in a project, I want to use a python function from a project in Github, I can't install this project as a library with pip install dicom-exporter because it doesn' work.

The project I want to use:

https://github.com/KitwareMedical/dicom-exporter/

the function I want to use :

dicom-exporter <path/to/dicom/folder> <path/to/output.vti>

The project contain setup.py file where there is script entry-point,

Please How can use this project in my django project.

CodePudding user response:

there is a simple way to do this in python

  1. make sure that the file you want to import your function from is in the same directory as your project
  2. make sure that the file you are importing the function from isn't named like an already existing python module
  3. you can import the function into your project by writing into your project: from [name of the file that contains the function] import [name of the function you want to import]

In this very case though you can simply type in your terminal pip install . as stated here

CodePudding user response:

Its very simple as the Readme file in the project says you would use pip install that ends with a dot. But you will need to open the where you downloaded the project, in its directory contains the Setup.py in your command prompt in other to use the [pip install .], so make sure to download the project clone as a zip file and unzip in to the directory where you will find it in your command prompt and run the pip install .

#First navigate to where the project directory contains the setup.py file in your 
# command prompt and run pip install that ends with a dot 
 pip install .
  •  Tags:  
  • Related