1

on editor Sublime Text 3, visual studio code, notepad++ or cmd the same problem

C:\Users\Egypt>python Desktop/python/any file.py

when i try run any file i get this

Traceback (most recent call last):
  File "Desktop/python/reqweb.py", line 1, in <module>
    from selenium import webdriver
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\__init__.py", line 18, in <module>
    from .firefox.webdriver import WebDriver as Firefox  # noqa
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 28, in <module>
    import shutil
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\shutil.py", line 22, in <module>
    import bz2
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\bz2.py", line 18, in <module>
    from threading import RLock
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\threading.py", line 7, in <module>
    from traceback import format_exc as _format_exc
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\traceback.py", line 5, in <module>
    import linecache
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\linecache.py", line 11, in <module>
    import tokenize
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\tokenize.py", line 34, in <module>
    from token import *
  File "C:\Users\Egypt\Desktop\python\token.py", line 1, in <module>
    import facebook
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\facebook\__init__.py", line 30, in <module>
    import requests
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\requests\__init__.py", line 43, in <module>
    import urllib3
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\__init__.py", line 8, in <module>
    from .connectionpool import (
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\site-packages\urllib3\connectionpool.py", line 3, in <module>
    import logging
  File "C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\logging\__init__.py", line 207, in <module>
    _lock = threading.RLock()
AttributeError: module 'threading' has no attribute 'RLock'

please help i try uninstall python and reinstall But the same problem this error Appears only in scripts inside import models

5
  • Please post your code. We cannot begin to help otherwise. Commented Aug 31, 2017 at 0:14
  • Does this happen when you just try and enter the Python interpreter (I.e when you just type "Python" with no argument?). Otherwise it's this a bug in a specific Python module you're trying to execute? Commented Aug 31, 2017 at 0:21
  • every code inside import some models Commented Aug 31, 2017 at 0:22
  • I think there is an error with the import in File "C:\Users\Egypt\Desktop\python\token.py", line 1, in <module> Commented Aug 31, 2017 at 1:03
  • thanks.. i delete this file and error disapear Commented Aug 31, 2017 at 10:24

1 Answer 1

1

I realize the comment above more or less resolved the issue, but to explain what was actually happening (because I just had a very similar problem and found this question):

It looks like your file C:\Users\Egypt\Desktop\python\token.py was incorrectly being picked as the source for the from token import * statement in the system's C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\tokenize.py module. It was actually intending to reference the module C:\Users\Egypt\AppData\Local\Programs\Python\Python35\lib\token.py. Since your version of the file wasn't what it expected, it raised an exception.

Either of these fixes should work in this case:

  1. Rename your token.py file to a non-conflicting name
  2. Don't execute python from this folder as the current directory.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.