Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am going through exercises using Eric pimpler's book Programming ArcGIS Pro with Python. I am running Juypter Notebook through ArcGIS Pro, the modules installed are arcpy and os.
Thank you.
Example:

Python
password = ''
while password != 'password':
    print("What is the password?")
    password = input()
print('Yes, the password is ' + password + '. You may enter.')


What is the password?
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
In [230]:
Line 4: password = input()

TypeError: 'str' object is not callable
---------------------------------------------------------------------------<

What I have tried:

Tried opening another notebook through ArcPro, copied the code and pasted it, initial success. Executed the code one more time failed. Code is all the occupies the current cell.
Posted
Updated 10-Jan-23 7:03am
v3
Comments
Richard MacCutchan 10-Jan-23 11:43am    
There is nothing wrong with that code (it works for me), so it is impossible to suggest anything. I can only assume something went wrong when you copied it into the notebook - which is a product I have never used.

If I copy and paste your code as you show it, it works fine.

But .... if I add one line, then it fails the same way you get:
Python
password = ''
input = ''
while password != 'password':
    print("What is the password?")
    password = input()
print('Yes, the password is ' + password + '. You may enter.')
It fails because I have declared a variable called input and that "overwrites" the definition of the standard function called input - so the system assumes you are trying to call a string as a function and complains.

Check your code above that, and see if you have a variable called input - and change it if you do!
 
Share this answer
 
Comments
David Jan2023 10-Jan-23 12:22pm    
That bit of code is all that occupies that particular cell. What I just did was launch the Jupyter from desktop and tried the code there and it worked. I saved my project in ArcGIS and closed it out and then opened it again and pasted the code it worked.
Either way thanks for you help, am completely new to programming so every bit of info helps.
OriginalGriff 10-Jan-23 12:47pm    
You're welcome!
Saved and closed Jupyter Notebook in ArcGIS Pro. Launched Jupyter notebook from the desktop, executed the code and had success. Open the ArcGIS Pro project again copied code from Jupyter notebook currently open through the desktop pasted and executed the code, success.
Feel a lot better now!

Thanks to OrginalGriff for his help!!
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900