2017-06-23 4 views
0

私はPyPiで私の最初のパッケージをアップロードしようとしています。私の機能がパッケージ内の関連するファイルにアクセスすることができない限り、すべてが良いと思われる。エラーは次のとおりです。PyPiの私のパッケージが関連するファイルを見つけられない

File "/Users/my_username/anaconda/lib/python3.6/site-packages/deepcut/deepcut.py", line 134, in tokenize 
with open('weight/object.pk', 'rb') as handle: 
FileNotFoundError: [Errno 2] No such file or directory: 'weight/object.pk' 

実際にピップが自分のファイルをパッケージにインストールしていることを確認しました。ここで私はパッケージを作成するために使用するフォルダが

LICENCE.txt 
MANIFEST 
MANIFEST.in 
README.rst 
setup.dfg 
setup.py 
deepcut 
    __init__.py 
    deepcut.py 
    weight 
    best_cnn.h5 
    object.pk 

で構成さ

__init__.py 
deepcut.py 
__pycache__ 
    ... 
weight 
    best_cnn.h5 
    object.pk 
/Users/my_username/anaconda/lib/python3.6/site-packages/deepcut私のインストールディレクトリ

には何かということですセットアップファイルの内容は次のとおりです。

from distutils.core import setup 
import setuptools 

setup(
    name = 'deepcut', 
    packages = ['deepcut'], 
    package_dir={'deepcut': 'deepcut'}, 
    package_data={'deepcut': ['weight/*']}, 
    include_package_data=True, 
    version = '0.5.0.13', 
    install_requires=['keras', 'pandas', 'scipy', 'numpy'], 
    license='MIT', 
    description = 'A Thai word tokenization library using Deep Neural Network', 
    author = 'Rakpong Kittinaradorn', 
    author_email = '[email protected]', 
    url = 'https://github.com/rkcosmos/deepcut', 
    download_url = 'https://github.com/rkcosmos/deepcut/package/0.5.zip', 
    keywords = ['thai word segmentation deep learning neural network development'], 
    classifiers = ['Development Status :: 3 - Alpha'], 
) 

とMANIFEST.in

# Include the license file 
include LICENSE.txt 
include README.rst 

# Include the data files 
recursive-include deepcut * 

答えて

1

かわりに、絶対パスを使用して試すことができます。

# this will be the path that the file is stored in 
# which for you should be /Users/my_username/anaconda/lib/python3.6/site-packages/deepcut/ 
path_to_module = os.path.dirname(__file__) 

# now just join it with the file in the weight folder 
weight_path = os.path.join(path_to_module, "weight", "object.pk") 
with open(weight_path, 'rb') as handle: 
    pass 
+0

それは私のためだけに機能しますが、他の人が私のパッケージをダウンロードするのはどうですか? –

+0

問題ではありません - 'path_to_module'は、パッケージのインストール場所に基づいて動的に計算されます。 – phd

+0

完璧!明確化のためにありがとう。 –

関連する問題