相談内容
head first pythonという本を独学で勉強しています。
pipを活用した自作モジュールを作る過程でエラーが発生しその解消方法(方針)をご教授いただきたいです。
やりたいこと
自身で作成したfunctionをsetuptoollsを活用して、site-packagesから引用できる状態を構築したい。
実施したこと
ステップ①:distribution discription作成
ステップ②:distribution file作成
ステップ③:distribution fileインストール(ここでエラーとなりつまずく)
状況
以下「実際したこと」の③にて以下エラーが
WARNING: The directory '/Users/sugimotoyuuki/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: Requirement 'vsearch-1.0.tar.gz' looks like a filename, but the file does not exist
Processing ./vsearch-1.0.tar.gz
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/sugimotoyuuki/PycharmProjects/mymodules/vsearch-1.0.tar.gz'
詳細
ステップ①:
(1)vsearch(今後引用したいfunction) (2)setup.py と (3)README.txt(ブランク)を作成
(1)vsearch
def search4letters(phrase:str, letters:str = 'aeiou') -> set:
'''Return a set of the 'letters' found in 'phrase'.'''
return set(letters).intersection(set(phrase))
(2)setup.py
from setuptools import setup
setup(
name = 'vsearch',
version = '1.0',
description = 'The Head First Python Search Tools',
author = 'HF Python 2e',
author_email = 'hfpy2e@gmail.com',
url = 'headfirstlabs.com',
py_modules = ['vsearch'],
)
ステップ②:
ステップ①のproject下のterminalで以下を実行
(base) sugimotoyuuki@sugimotoyuukinoMacBook-Air-2 mymodules % python3 setup.py sdist
running sdist
running egg_info
writing vsearch.egg-info/PKG-INFO
writing dependency_links to vsearch.egg-info/dependency_links.txt
writing top-level names to vsearch.egg-info/top_level.txt
reading manifest file 'vsearch.egg-info/SOURCES.txt'
writing manifest file 'vsearch.egg-info/SOURCES.txt'
running check
creating vsearch-1.0
creating vsearch-1.0/vsearch.egg-info
copying files to vsearch-1.0...
copying README.txt -> vsearch-1.0
copying setup.py -> vsearch-1.0
copying vsearch.py -> vsearch-1.0
copying vsearch.egg-info/PKG-INFO -> vsearch-1.0/vsearch.egg-info
copying vsearch.egg-info/SOURCES.txt -> vsearch-1.0/vsearch.egg-info
copying vsearch.egg-info/dependency_links.txt -> vsearch-1.0/vsearch.egg-info
copying vsearch.egg-info/top_level.txt -> vsearch-1.0/vsearch.egg-info
Writing vsearch-1.0/setup.cfg
Creating tar archive
removing 'vsearch-1.0' (and everything under it)
ステップ③:
ステップ②によって生成されたdistファイルの環境下で
以下をterminal内で実施→エラーとなる
(base) sugimotoyuuki@sugimotoyuukinoMacBook-Air-2 mymodules % sudo python3 -m pip install vsearch-1.0.tar.gz
Password:
WARNING: The directory '/Users/sugimotoyuuki/Library/Caches/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
WARNING: Requirement 'vsearch-1.0.tar.gz' looks like a filename, but the file does not exist
Processing ./vsearch-1.0.tar.gz
ERROR: Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/Users/sugimotoyuuki/PycharmProjects/mymodules/vsearch-1.0.tar.gz'