Python Forum
I cannot import the module I built for pypi
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I cannot import the module I built for pypi
#2
You have build it as a package.
Then is your folder named src also part of import.
(my_env) E:\1\my_env
λ pip install catslog
Collecting catslog
  Downloading catslog-1.0.5.tar.gz
Installing collected packages: catslog
  Running setup.py install for catslog ... done
Successfully installed catslog-1.0.5

>>> import src
>>> src.catslog
<module 'src.catslog' from 'E:\\1\\my_env\\lib\\site-packages\\src\\catslog.py'>
>>> help(src.catslog)
Help on module src.catslog in src:

NAME
    src.catslog

FUNCTIONS
    catslog(f)

FILE
    e:\1\my_env\lib\site-packages\src\catslog.py
If it's a singe module can use py_modules=['catslog'] in setup.py,and just drop package.
Eg
# setup.py
from setuptools import setup
 
__author__ = 'you'
 
setup(
   name="catslog",
   version='0.1',
   py_modules=['catslog'],
   description="Something",
   url='',
   author_email='something@',
)
You should always build wheel and not source distributions(sdist).
python setup.py bdist_wheel
Reply


Messages In This Thread
RE: I cannot import the module I built for pypi - by snippsat - Apr-10-2018, 07:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  is import cointegration_analysis a recognized module mitcht33 1 563 Nov-06-2023, 09:29 PM
Last Post: deanhystad
  problem in import module from other folder akbarza 5 1,881 Sep-01-2023, 07:48 AM
Last Post: Gribouillis
  can not import anaconda pandas module. PySpark pandas module is imported!! aupres 0 843 Aug-06-2023, 01:09 AM
Last Post: aupres
  import module error tantony 5 3,745 Dec-15-2022, 01:55 PM
Last Post: Lauraburmrs
  Import a module one step back of the path prathampatel9 1 1,174 Sep-21-2022, 01:34 PM
Last Post: snippsat
  Import a module for use in type hint? Milosz 0 1,583 Nov-08-2021, 06:49 PM
Last Post: Milosz
  Can't install nor import delorean module Tek 3 3,008 Oct-27-2021, 03:32 AM
Last Post: Tek
  import module with syntax error Skaperen 7 5,657 Jun-22-2021, 10:38 AM
Last Post: Skaperen
  'urllib3' Module not found when import 'requests' spanz 5 10,955 Jan-06-2021, 05:57 PM
Last Post: snippsat
  Problem with Flask Bcrypt import module marcello86 2 6,028 Aug-31-2020, 08:10 PM
Last Post: marcello86

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020