Python Forum
Broken interpreter? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Broken interpreter? (/thread-23383.html)



Broken interpreter? - fcktheworld587 - Dec-26-2019

Whenever i try to run a script through Python 3.8 it gives me the following output:
Output:
Please enter a string: (a)There is a total of 0 characters in the string. (b) (c) (d) (e) (f) (g) There are not seven characters in that string (h) (i) (j) (k) Traceback (most recent call last): File "lucky.py", line 4, in <module> import requests, sys, webbrowser, bs4 File "/usr/local/lib/python3.8/site-packages/requests/__init__.py", line 43, in <module> import urllib3 File "/usr/local/lib/python3.8/site-packages/urllib3/__init__.py", line 7, in <module> from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url File "/usr/local/lib/python3.8/site-packages/urllib3/connectionpool.py", line 3, in <module> import logging File "/usr/local/lib/python3.8/logging/__init__.py", line 28, in <module> from string import Template ImportError: cannot import name 'Template' from 'string' (/home/computer/First_Programs/string.py)
Can somebody please help me?


RE: Broken interpreter? - snippsat - Dec-26-2019

Give your file an other name than string.py.
This will shadowing a built-in module string.
>>> import string
>>> 
>>> string.ascii_lowercase
'abcdefghijklmnopqrstuvwxyz'
So this import use a filled called string.py.