1

I'm trying to write my own setup.py to be able to import the module but I get errors

import mylib
>>> ModuleNotFoundError: No module named 'mylib'

My problem is that I do not understand why this is happening.

Currently I'm using windows and conda and have created an evnironment named "rig" where i try to install the packaged by:

(rig) C:\> pip install -e "path to lib"

After installation I can see that the lib has been installed

pip list
>> ...
>> mylib (1.2.3)
>> ...

It seems like the correct python executable are used:

import sys"
print(sys.executable)
>>>C:\ProgramData\Anaconda3\envs\rig\python.exe

how can it be that pip lists the module but it's not possible to import it? How do I debug this problem, suggestions?

my setup.py file:

from setuptools import setup, find_packages



setup(name='mylib',
  description="experimental platform for ejector-program",
  author="Daniel Grafstrom",
  version='1.2.3',
  license='GPLv3',
  packages = ['JetFiles'],        #packages=find_packages(exclude=['examples','tests']),
  install_requires=['mongoengine',
                    'pandas',
                    'numpy',
                    'pyvalid'],
  )

3 Answers 3

3

I think you have wrong import. Because setup name != real package name

Try:

import JetFiles

Also check you run python in venv or not.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot, that helped.
0

Check that the path to python.exe which usually in a desktop env is at C:\PythonXX\' is the same as the python\scripts folder wherepip` is located and therefore the modules that are being retrieved later.

I've encountered something similar sometimes when having installed python 2.7 and 3.x at the same time and having as env. variable C:\Program Files\Python36 but pip pointing to C:\Python27.

Comments

0

You need create your program by a structure for use setuptools. Try to read this https://pythonhosted.org/an_example_pypi_project/setuptools.html Now you can import setup from setuptools and tell setup function. for example:

from setuptools import setu
setup(
    name = "yourProgram",
    version = "1",
    author = "you",
    author_email = "[email protected]",
    description = (""),
    keywords = "",
    url = "",
    packages=['', ''],
    long_description=read('README'),)

1 Comment

Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.