简体   繁体   中英

Python package installation issues

python setup.py install is resulting in improper installations where the .egg-info folder isn't placed in the correct location and any sub folder of the setup.py package is also not copied into /Lib/site-packages.

I must not be installing the package correctly but so frequently, python packages have little to no readme/install information despite there seeming to be some different approaches.

pip install x almost always works if it is supported but the packages that are on git or elsewhere that don't have a pip reference, are often not properly installed when running the setup.py.

Specific issue:

PS C:\Python34> .\python.exe C:\py\sanction-master\setup.py install
running install
running bdist_egg
running egg_info
creating sanction.egg-info
writing sanction.egg-info\PKG-INFO
writing top-level names to sanction.egg-info\top_level.txt
writing dependency_links to sanction.egg-info\dependency_links.txt
writing manifest file 'sanction.egg-info\SOURCES.txt'
warning: manifest_maker: standard file 'setup.py' not found

error: package directory 'sanction' does not exist

There is zero information on installing the package and it doesn't install properly. Even after copying the sanction and sanction.egg-info folders into site-packages, the setup still says it can't find package directory. Haven't tested the package but it's not clear whether it was installed right or not.

Why is what I'm doing wrong in this case and what is the right way to install this package (or others similar)?

setup.py needs to be run while in the folder that contains it. This is because some parts of the process rely on using relative paths, and if you're in another directory those paths cannot be found. This also explains why you were finding .egg-info files/directories in incorrect places.

You can use pip to install from Github or other VCS repos : just prepend git+ to the URL:

pip install git+https://github.com/username/reponame.git

Alternatively, as noted in the comments, you can go to the project's Github page and click on the Download ZIP link on the right to get a zipfile of the repo. Unzip the file, then run

pip install file://path/to/unzipped/directory

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM