1

I have just created a Python package and uploaded it to PyPi (goosempl). Installing the package locally works:

$ python3 setup.py install

(It installs in usr/local/lib/python3.6/site-packages).

However installing it from PyPi gives a weird error:

$ pip3 install goosempl

...
PermissionError: [Errno 13] Permission denied: '/usr/local/goosempl' 

For some reason pip tries to install in the wrong location?!?


Here is the setup.py (stripped down a bit, it still causes the error):

import atexit
from setuptools import setup

__version__ = '0.1.0'

setup(
    name              = 'goosempl',
    version           = __version__,
    author            = 'Tom de Geus',
    author_email      = '[email protected]',
    url               = 'https://github.com/tdegeus/GooseMPL',
    keywords          = 'matplotlib style',
    description       = 'Style and extension functions for matplotlib',
    long_description  = '',
    license           = 'MIT',
    install_requires  = ['matplotlib>=2.0.0'],
    packages          = ['goosempl'],
    data_files        = [('goosempl/stylelib',[
        'goosempl/stylelib/goose.mplstyle'
    ])],
)

I have uploaded it to PyPi using:

$ python3 setup.py sdist
$ python3 setup.py bdist_wheel --universal
$ twine upload dist/*

(My guess in that the problem is caused by the data_files)

6
  • are you inside a virtualenv? May 5, 2017 at 9:08
  • @NilsWerner No I'm not. (Furthermore, I'm using the homebrew Python on Mac) May 5, 2017 at 9:08
  • It may be that data_files is the culprit, (goosempl/stylelib doesn't get expanded to /usr/local/lib/python3.6/site-packages/goosempl/stylelib but /usr/lib/goosempl/stylelib). Try removing the lines and instead create a MANIFEST.in file containing just the line goosempl/stylelib/goose.mplstyle. May 5, 2017 at 9:13
  • Also, did you really mean python3 install setup.py, or rather python3 setup.py install? May 5, 2017 at 9:18
  • @NilsWerner With your directions I have solved it by changing data_files with package_data (with a slightly different syntax). But maybe you are better equipped to explain this difference, and the relation to MANIFEST.in? May 5, 2017 at 9:23

1 Answer 1

0

With the help of @NilsWerner:

The problem was in data_files. I have changed this with package_data (which has a slightly different syntax):

package_data = {'goosempl/stylelib':[
    'goosempl/stylelib/goose.mplstyle'
]}, 

This results in the desired behavior.

Following the comments, one could also include these files in MANIFEST.in.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.