'How to create a library in Python that available to be called in prompt?
I need to create a simple library that will work in that way:
- I run python command prompt interpreter from Windows Start
- Write
import <a name of library> - Then write
m_relation(<arguments>) - Interpreter shows a result of what I need
I already have written down the code I need.
Solution 1:[1]
firstly you can make a folder for your package in this path:
C:\Users\youruser\AppData\Local\Programs\Python\Python310\Lib\site-packages\
for example new_folder,
then you make or paste your library in this path,
after that you should make a setup.py file in this folder that contain this sample code:
from setuptools import setup
setup(
name='My First Setup File',
version='1.0',
scripts=['your_file.py'],
)
then you open cmd in this path and run :
python setup.py install
eventually you can use this library from cmd.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mohammad |
