Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
site packages, python 3.8
#1
from setuptools import setup

setup(
    name = 'vsearch'
    version = '1.0'
    description = 'The Head First PYthon Search Tools',
    author = 'HF Python 2e',
    author_email = '[email protected]',
    url = 'headfirstlabs.com',
    py_modules = ['vsearch'],
    )
For reasons unknown to me, this doesn't fully work. I'm supposed to get a zip file in Windows 10, but get a tar.gz instead, which if I understand, is for the Unix OS. I invoke it with C:\users\dixon\appdata\local\programs\python\python38-32\mymodules\python setup.py sdist

I'm supposed to now be able to access my modules from any file location on my computer, right? Again, this is from 'Head First Python', as would seem obvious from the code. Rolleyes
Reply
#2
What happens if you explicitly specify file formats in the cli with --formats option? The docs state that default format on windows is zip, but anyway it's worth a try

As stated in the docs:

Quote: In the simplest case,
python setup.py sdist
(assuming you haven’t specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

You can specify as many formats as you like using the --formats option, for example:

python setup.py sdist --formats=gztar,zip
to create a gzipped tarball and a zip file.

as a side note you can open tar files on widows
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
(Jan-24-2020, 08:42 AM)buran Wrote: What happens if you explicitly specify file formats in the cli with --formats option? The docs state that default format on windows is zip, but anyway it's worth a try

As stated in the docs:

Quote: In the simplest case,
python setup.py sdist
(assuming you haven’t specified any sdist options in the setup script or config file), sdist creates the archive of the default format for the current platform. The default format is a gzip’ed tar file (.tar.gz) on Unix, and ZIP file on Windows.

You can specify as many formats as you like using the --formats option, for example:

python setup.py sdist --formats=gztar,zip
to create a gzipped tarball and a zip file.

as a side note you can open tar files on widows

OK, your tip works as far as getting the 'vsearch-1.0.zip' into the dist directory. So now I'm supposed to be able to access vsearch module from any location on my computer if I understand. Still a no go, and I can't find help online, nor does the book have anything to say about figuring out the error.
Reply
#4
(Jan-24-2020, 09:49 PM)Dixon Wrote: So now I'm supposed to be able to access vsearch module from any location on my computer if I understand.
No that is source distribution (sdist), i.e. as the name suggests its for distribution.
you need to install it with pip
https://packaging.python.org/tutorials/i...-vs-wheels
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#5
Use bdist_wheel so you get the real wheel format .whl.
Example to 3.8 not in my Path so take in from Scripts folder,and call it vvsearch to avoid name conflict.
# vvsearch.py
def search4vowels(phrase: str) -> set:
    vowels = set('aeiou')
    return vowels.intersection(set(phrase))

def search4letters(phrase: str, letters: str) -> set:
    return set(letters).intersection(set(phrase))

if __name__ == '__main__':
    print(search4letters('hitch-hiker', 'aeiou'))
    print(search4letters('galaxy', 'xyz'))
    print(search4letters('life, the universe, and everything', 'o'))
# setup.py
from setuptools import setup

setup(
   name="vvsearch",
   version='1.0',
   py_modules=['vvsearch'],
   description="Search Tool",
   url='https://python-forum.io/index.php',
   author_email='[email protected]',
)
Command line i use cmder,just the same in cmd
# Install wheel
C:\Python38\Scripts
λ pip install wheel
Collecting wheel
  Using cached https://files.pythonhosted.org/packages/00/83/...c9/wheel-0.33.6-py2.py3-none-any.whl
Installing collected packages: wheel
Successfully installed wheel-0.33.6

# Make the wheel
C:\Python38\Scripts
λ py -3.8 setup.py bdist_wheel
....
adding 'vvsearch-1.0.dist-info/top_level.txt'
adding 'vvsearch-1.0.dist-info/RECORD'
removing build\bdist.win32\wheel

# Now the wheel is in dist folder,install with pip
C:\Python38\Scripts\dist
λ py -3.8 -m pip install vvsearch-1.0-py3-none-any.whl
Processing c:\python38\scripts\dist\vvsearch-1.0-py3-none-any.whl
Installing collected packages: vvsearch
Successfully installed vvsearch-1.0

# Test that it work 
C:\Python38
λ python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import vvsearch
>>>
>>> vvsearch.search4letters('hitch-hiker', 'aeiou')
{'e', 'i'}
>>> vvsearch.search4letters('hello', 'aeiou')
{'e', 'o'}
>>> exit()
So now it install to 3.8.
This is just the same way you make it if want to use PyPi.
PyPi is a central disruption of wheels.

After upload wheel to PyPi your wheel get shorter name.
# This can share with other eg usb stick,private host of wheel on web
pip install vvsearch-1.0-py3-none-any.whl

# PyPi share with other in an easier way
pip install vvsearch 
It's just the same wheel PyPi disturbed it central.
Reply
#6
This is what I get when I follow instructions in the "Head First Python" book from page 182. If I'm supposed to format this in some specific way, I'm sorry. Anyway, now the computer can't find the 'pip' module.

C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\mymodules\dist>python -m pip install vsearch-1.0.zip
Traceback (most recent call last):
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\__main__.py", line 19, in <module>
sys.exit(_main())
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\commands\__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\commands\install.py", line 20, in <module>
from pip._internal.cache import WheelCache
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\cache.py", line 19, in <module>
from pip._internal.wheel import InvalidWheelFilename, Wheel
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\wheel.py", line 42, in <module>
from pip._internal.utils.setuptools_build import make_setuptools_shim_args
ModuleNotFoundError: No module named 'pip._internal.utils.setuptools_build'
Reply
#7
(Jan-27-2020, 11:10 PM)Dixon Wrote: This is what I get when I follow instructions in the "Head First Python" book from page 182
Follow mine instruction they are more up to date.

Dos your pip work now?
From cmd,it should work just the same for you but point to 3.8:
# Test pip
C:\>pip -V
pip 19.2.3 from c:\python37\lib\site-packages\pip (python 3.7)

# Test install,wheel as you need
C:\>pip install wheel
Collecting wheel
  Downloading .....
Successfully installed wheel-0.34.1

# Upgrade pip
C:\>python -m pip install --upgrade pip
Collecting pip ..... 
Successfully installed pip-20.0.2

# Test pip again,see that is 20.0.2
C:\>pip -V
pip 20.0.2 from c:\python37\lib\site-packages\pip (python 3.7)
Reply
#8
Still having problems:

C:\Users\Dixon>cd appdata\local\programs\python

C:\Users\Dixon\AppData\Local\Programs\Python>cd python38-32\mymodules\dist

C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\mymodules\dist>python -m pip install vsearch-1.0.zip
Traceback (most recent call last):
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 193, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\__main__.py", line 19, in <module>
sys.exit(_main())
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\commands\__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\commands\install.py", line 20, in <module>
from pip._internal.cache import WheelCache
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\cache.py", line 19, in <module>
from pip._internal.wheel import InvalidWheelFilename, Wheel
File "C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pip\_internal\wheel.py", line 42, in <module>
from pip._internal.utils.setuptools_build import make_setuptools_shim_args
ModuleNotFoundError: No module named 'pip._internal.utils.setuptools_build'

C:\Users\Dixon\AppData\Local\Programs\Python\Python38-32\mymodules\dist>
Reply
#9
Could you do the same test as posted,also test pip and install wheel to see if that work.
Then also in post #5 there is a complete setup to make wheel,and no use of .zip but .whl(the real wheel format).
Reply
#10
I'll do it tomorrow. Time for Chardonay. :-)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Installing python packages in a virtual environment Led_Zeppelin 1 763 Aug-15-2023, 08:18 PM
Last Post: deanhystad
  Installation of packages to newest Python version from previous one Andrzej_Andrzej 3 841 Jul-15-2023, 11:32 AM
Last Post: snippsat
  site-packages issue paulgureghian 3 1,354 Jul-07-2022, 04:15 PM
Last Post: snippsat
  Troubleshooting site packages ('h5py' to be specific) aukhare 2 2,000 Nov-02-2020, 03:04 PM
Last Post: snippsat
  How to create local copies of Python packages so they do not have to be downloaded okhajut 3 2,024 Sep-29-2020, 02:22 PM
Last Post: buran
  python interpreter won't import packages greenpy 1 1,976 Sep-11-2020, 07:47 PM
Last Post: buran
  Conversion of Oracle PL/SQL(packages, functions, procedures) to python modules. DivyaKumar 2 6,496 Jul-09-2020, 04:46 PM
Last Post: srikanth7482
  Site packages, Python 3.8 Dixon 2 2,512 Jan-18-2020, 10:42 PM
Last Post: Dixon
  Python 3.8 or 3.? Trouble installing packages dn237 5 6,794 Oct-25-2019, 07:21 PM
Last Post: snippsat
  Python packages - quality j.crater 8 5,747 Mar-13-2017, 08:58 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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