简体   繁体   中英

Adding your own python project source code to site-packages folder using setuptools (setup.py install)

I'm aware there are similar questions to such as this one, but I have trouble understanding how to actually automatically create module in site-packages for my own project.

I tried using python setup.py install and it created .egg file in my site-packages but I can't import it in simple python script.

I tried googling for about an hour now and the only solution I found is to directly copy the sources to a directory which I don't want to do as I'd have to copy it every time I change my project.

I figured out my problem.

pip install .

Inside the project directory is actually giving me the wanted output, but problem is that I didn't nest the name of my package inside project.

Think, I have project foo, and I want to have imports such as:

from foo import bar

Well I had project named foo but I didn't have first package named foo rather I had straight away bar and all other packages, so that was the mistake.

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