Dalhoumi Jasser Dalhoumi Jasser -4 years ago 105
Python Question

My setup.py can't define the script when I try to install it

I've been trying to learn Python via "Learn Python the Hard Way", and in ex46 he told us to put a script in bin and install it with

setup.py
.

My script's name was
testscript3.py
:

from test3 import printstring

printstring.printstring("this is a test")


test3.py
was like that:

def printstring(s='you did not provide string'):
print s


After making them I added the script to the
setup.py
:

'scripts': [bin/testscript3.py],


and in PowerShell I wrote:

python setup.py install


in order to install it, but I got an error:


testscript3 is not defined


I tried to import it by doing:

from bin import testscript3


but still getting the same problem.

Answer Source

You need to use a string in your setup.py The reason you're getting testscript3 is not defined is because without the quotes around bin/testscript3.py Python expects bin/testscript3.py to be a variable.

'scripts': ['bin/testscript3.py'],
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download