Tweepy: ImportError: Impossible to import Random name

I use Tweepy to post to Twitter. I get a long trace from the API. The trace is located at:

ImportError: cannot import name Random 

I used Pip to install the latest version of Tweepy:

 Name: tweepy Version: 2.3.0 Location: /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages Requires: 

When i call

 import tweepy 

I get this trace:

 Traceback (most recent call last): File "/Users/dromard/Projects/Drop Playlist/drop.py", line 4, in <module> import tweepy File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/__init__.py", line 14, in <module> from tweepy.api import API File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/api.py", line 8, in <module> from tweepy.binder import bind_api File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/tweepy/binder.py", line 5, in <module> import httplib File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 79, in <module> import mimetools File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/mimetools.py", line 6, in <module> import tempfile File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/tempfile.py", line 35, in <module> from random import Random as _Random ImportError: cannot import name Random Process finished with exit code 1 

I work in PyCharm and validated the site package, and the Python paths are correct in the settings. I manually checked in the console that the paths are correct and that there are no duplicate locations.

I have not made any changes to Tweepy. I let Pip install it where it is, as it is. Permissions look right:

 -rw-r--r-- 1 root wheel 

If I check Python on the console:
- I get the same trace
- When I start individual import, all of them are executed without errors

All this does not work when calling random . I think random is part of the Python kernel packages, not part of Tweepy.

I passed this script to an employee who then used Pip to set tweepy and hit the same trace. It makes me think that Pip can contribute.

I am relatively new to Python (programming in general). I looked at other articles about the import error, but did not find this specific problem. Any help is appreciated.

+6
source share
1 answer

I get it. I created a python file called "random.py" while experimenting with a random number generating a script. My "import random" call captured this file, which did not have a Random library. This essentially created a conflict with the correct "random."

+18
source

Source: https://habr.com/ru/post/975039/


All Articles