Reputation: 255
I'm trying to install a python package in windows 10 using the following setup.py file.
"""Setup file for uhd module"""
from setuptools import setup
setup(name='uhd',
version='3.14.0',
description='Universal Software Radio Peripheral (USRP) Hardware Driver Python API',
classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: C++',
'Programming Language :: Python',
'Topic :: System :: Hardware :: Hardware Drivers',
],
keywords='SDR UHD USRP',
author='Ettus Research',
author_email='[email protected]',
url='https://www.ettus.com/',
license='GPLv3',
package_dir={'': 'C:/Users/bcollins/UHD_PY/uhd/host/build/python'},
package_data={'uhd': ['*.so']},
zip_safe=False,
packages=['uhd'],
install_requires=['numpy'])
I execute the script using the command
python setup.py install
I do this from the directory that contains the setup.py file.
This returns the following error
error: package directory 'C:Users\bcollins\UHD_PY\uhd\host\build\python\uhd' does not exist
There is a folder called "uhd" at that location though. The folder contains the __init__.py
file
If the script isn't looking for this folder, what is it looking for?
I'm not exactly experienced in this area but my best guess is that its looking for a .so file within the "uhd" folder at that location, but I'm not sure.
I am using python 2.7.
Upvotes: 22
Views: 49973
Reputation: 490
I found out that this error can occur when the python scripts folder (%python_root%\scripts) is not in the environment PATH.
Upvotes: -1
Reputation: 21
To react to @MickeyDickey's comment, you can still successfully build your package with setup.py
even if you use a src-layout. You just have to provide this: package_dir = {"": "src"}
to the setup
function. See setuptools documentation for more information.
Ending with something like this:
from setuptools import setup, find_packages
setup(
...
packages=find_packages('src', exclude=['test']),
package_dir = {"": "src"},
...
)
Upvotes: 2
Reputation: 357
For me kelloti's answer removed the error. But the package was still not being built right. It would get built empty.
I solved this by using pyproject.toml
instead of setup.py
format of the config file.
Somehow, the options presented in the setuptools docs for setup.py:
packages=find_packages(
where='src',
include=['mypackage'],
),
Just don't work right. They either produce an empty package, or a package named "src", with my actual package inside of it.
Using the exact same options but in pyproject.toml
config file works properly:
[tool.setuptools.packages.find]
where = ["src"]
include = ["mypackage*"]
And I am no longer having errors when building, while my package is installed properly(rather than being installed under src
directory)
Upvotes: 1
Reputation: 76
I had this problem, it turned out that you just need to add a slash after your package directory: packages=['uhd']
should be packages=['uhd/']
.
Upvotes: 2
Reputation: 8951
This doesn't answer the original question, but it's how I fixed the same error.
I had:
from setuptools import setup, find_packages
setup(
...
packages=find_packages('src', exclude=['test']),
...
)
I had added the src
argument because my packages are located in src
, but it turns out find_packages
is smart enough on it's own.
Remove the first argument:
from setuptools import setup, find_packages
setup(
...
packages=find_packages(exclude=['test']),
...
)
This was on Python 3.5, but I imagine it applies to most other versions.
Upvotes: 25
Reputation: 280564
package_dir
has to be a relative path, not an absolute path. The distutils layer under setuptools tries to reject absolute paths, but the C:
confuses it. It ends up converting your path to
C:Users\bcollins\UHD_PY\uhd\host\build\python\uhd
Note the missing backslash between C:
and Users
. This path is relative to your current working directory on the C drive (windows drive handling is weird), and relative to your working directory, this path is invalid.
Upvotes: 6