Gianluca
Gianluca

Reputation: 6657

Importing *asyncio* in Python 3.5.2 cause ImportError due to *Full* being shadowed

In Python 3.5.2 importing asyncio raises an ImportError.

Python 3.5.2 (default, Nov 17 2016, 17:05:23) 
Type "copyright", "credits" or "license" for more information.

IPython 5.2.2 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import asyncio
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-1-dc80feba2326> in <module>()
----> 1 import asyncio

/usr/lib/python3.5/asyncio/__init__.py in <module>()
     19 
     20 # This relies on each of the submodules having an __all__ variable.
---> 21 from .base_events import *
     22 from .coroutines import *
     23 from .events import *

/usr/lib/python3.5/asyncio/base_events.py in <module>()
     16 
     17 import collections
---> 18 import concurrent.futures
     19 import heapq
     20 import inspect

/usr/lib/python3.5/concurrent/futures/__init__.py in <module>()
     15                                       wait,
     16                                       as_completed)
---> 17 from concurrent.futures.process import ProcessPoolExecutor
     18 from concurrent.futures.thread import ThreadPoolExecutor

/usr/lib/python3.5/concurrent/futures/process.py in <module>()
     50 from concurrent.futures import _base
     51 import queue
---> 52 from queue import Full
     53 import multiprocessing
     54 from multiprocessing import SimpleQueue

ImportError: cannot import name 'Full'

This is the output of pip freeze:

aiohttp==1.3.3
appdirs==1.4.0
async-timeout==1.1.0
chardet==2.3.0
decorator==4.0.11
ipython==5.2.2
ipython-genutils==0.1.0
multidict==2.1.4
numpy==1.12.0
packaging==16.8
pexpect==4.2.1
pickleshare==0.7.4
prompt-toolkit==1.0.13
ptyprocess==0.5.1
Pygments==2.2.0
pyparsing==2.1.10
scipy==0.18.1
simplegeneric==0.8.1
six==1.10.0
traitlets==4.3.1
wcwidth==0.1.7
yarl==0.9.8

How can I import asyncio in such case?

Upvotes: 1

Views: 2287

Answers (1)

Udi
Udi

Reputation: 30512

Check if your project or current working directory includes a file called queue.py and rename it. (According to your comment, it is the file /home/gianluca/git/python/asyncio/queue.py.)

Upvotes: 2

Related Questions