-2

I want to share my python code with my colleague in a way that he will get the distribution package and using pip the package can be installed on his/her machine.

I created .whl file which i thought can be directly installed through the pip install command. Though it was installed successfully, when i start using it shows the error.

Is this possible like i give .whl file and it can be used in other's machine once installed through pip install command ?

I'm trying to do it on windows machine.

Here is the setup.py :

import setuptools
with open("README.md", "r") as fh:
    long_description = fh.read()
setuptools.setup(
     name='dokr',  
     version='0.1',
     scripts=['dokr'] ,
     author="Debapritam Chakra",
     author_email="debapritam22@gmail.com",
     description="A Sample package",
     long_description=long_description,
   long_description_content_type="text/markdown",
     url="",
     packages=setuptools.find_packages(),
     classifiers=[
         "Programming Language :: Python :: 2.7",
         "",
         "Operating System :: OS Independent",
     ],
 )

package that i am trying to create is dokr and have file named dokr in the same directory which has the content shown below.

#!/usr/bin/env python
echo "hey there, this is a pip package"

used the command python setup.py sdist bdist_wheel to generate the distribution package.

To install package on my machine, I used the command :

python -m pip install dist/name-of-wheel-file.whl

It showed it is installed successfully(even checked using the pip list). It throws the error when i try to import the package as

import dokr

Traceback (most recent call last):

File "", line 1, in

ImportError: No module named dokr

Additional observation : Python on my machine is installed under C:\Python27. After installing the package from whl file using pip, I could see there is a directory created under the path : C:\Python27\Lib\site-packages\ named dokr-0.1.dist-info.For which pip list shows that the module is present.

But there is no such folder having the python file dokr itself, which i want to import in other python file. which shows error during importing.

I am new to python and this platform as well. Any lead would be helpful.

Karvan
  • 1
  • 2

2 Answers2

0

Ofcourse, you can create a python distribution package.

Can you clearly show what is the error? However, you can look into the following link! : Packaging Python Projects

Hope this helps!

S M Vaidhyanathan
  • 320
  • 1
  • 4
  • 13
0

Fortunately found the cause of the problem.

I did not pass the argument( packages which takes the list of packages to be included ) in the setup function, for which packages could not be copied.

Following article and an awesome answer helped to sort out the issue.

https://setuptools.readthedocs.io/en/latest/setuptools.html#developer-s-guide

pip install . creates only the dist-info not the package

And I thank everyone who came here to help. :)

Karvan
  • 1
  • 2