Sublime Forum

ImportError: cannot import name 'NAME OF FILE HERE'

#1

Hey guys so recently i installed sublime text 3 on Ubuntu 17.04 but for some reason when I try to run packages I install (not standard library) it gives the error above. it all gives a traceback error with a bunch of file paths.

code in sublime: Import Discord

Output:

Traceback (most recent call last):
File “/home/moro/Documents/random.py”, line 1, in
import discord
File “/usr/local/lib/python3.6/site-packages/discord/init.py”, line 20, in
from .client import Client, AppInfo, ChannelPermissions
File “/usr/local/lib/python3.6/site-packages/discord/client.py”, line 28, in
from .user import User
File “/usr/local/lib/python3.6/site-packages/discord/user.py”, line 27, in
from .utils import snowflake_time
File “/usr/local/lib/python3.6/site-packages/discord/utils.py”, line 31, in
import asyncio
File “/usr/local/lib/python3.6/asyncio/init.py”, line 21, in
from .base_events import *
File “/usr/local/lib/python3.6/asyncio/base_events.py”, line 17, in
import concurrent.futures
File “/usr/local/lib/python3.6/concurrent/futures/init.py”, line 17, in
from concurrent.futures.process import ProcessPoolExecutor
File “/usr/local/lib/python3.6/concurrent/futures/process.py”, line 55, in
from multiprocessing.connection import wait
File “/usr/local/lib/python3.6/multiprocessing/connection.py”, line 18, in
import tempfile
File “/usr/local/lib/python3.6/tempfile.py”, line 45, in
from random import Random as _Random
ImportError: cannot import name ‘Random’
[Finished in 0.1s with exit code 1]
[cmd: [‘python3.6’, ‘-u’, ‘/home/moro/Documents/random.py’]]
[dir: /home/moro/Documents]
[path: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin]

to verify it wasn’y my installation I ran python in the terminal and got no error as seen here:

moro@Falco123:~$ python3
Python 3.6.2 (default, Aug 16 2017, 16:00:27)
[GCC 6.3.0 20170406] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
[3 arrows] import discord
[3 arrows]

no error was outputed.

Also for reference I will put my build system to rule out an error there:

{
“cmd”: [“python3.6”, “-u”, “$file”],
“file_regex”: “^[ ]File “(…?)”, line ([0-9]*)”,
“selector”: “source.python”,
}

If you need further information or have ideas for me to try post, thanks

0 Likes

#2

What happens when you rename random.py in /home/moro/Documents to something else?

0 Likes

#3

huh what a silly mistake. Must have been because random is a package name. Well I feel stupid thanks!

1 Like