0

I am testing python code performance with uvloop. I am getting 'uvloop' has no attribute 'EventLoopPolicy' error. I am using python 3.7 and uvloop 0.13.0 pycharm

I tried changing interpreter reinstalling uvloop but none of them did not work. Can anyone suggest what is the problem?

enter image description here

Eranga Perera
  • 908
  • 1
  • 11
  • 21

2 Answers2

0

I see that you're on a Mac, but I just fixed this problem on my CentOS7.x server by properly setting permissions to the uvloop Python package. It's pesky because (at least on CentOS) some pip-installed Python packages go in /usr/local/lib/python3.7/site-packages and some go in /usr/local/lib64/python3.7/site-packages.

Check out what the files in my lib64 directory looked like before I fixed it:

me@myserver /usr/local/lib64/python3.7/site-packages
$ ll
total 16
drwxr-xr-x. 3 root root 4096 Jan 17 15:38 click
drwxr-xr-x. 2 root root  134 Jan 17 15:38 Click-7.0.dist-info
drwxr-x---. 4 root root   74 Jan 17 15:42 httptools
drwxr-x---. 2 root root  141 Jan 17 15:42 httptools-0.0.13-py3.6.egg-info
drwxr-x---. 3 root root 4096 Jan 17 15:43 pydantic
drwxr-x---. 2 root root  111 Jan 17 15:43 pydantic-1.3.dist-info
drwxr-x---. 5 root root 4096 Jan 17 15:43 uvloop
drwxr-x---. 2 root root  141 Jan 17 15:43 uvloop-0.14.0-py3.6.egg-info
drwxr-xr-x. 4 root root 4096 Jan 17 15:38 websockets
drwxr-xr-x. 2 root root  134 Jan 17 15:38 websockets-8.1.dist-info

Unless I was running as a root user the uvloop files are untouchable and that's what caused the error. On your Mac, try to find where your uvloop package is installed and make sure your script can access it.

blahblahetcetc
  • 191
  • 1
  • 6
  • You shouldn't be installing any packages system-wide anyway, but use either user site-packages directories or virtualenvs. – AKX Jan 21 '20 at 19:56
0

Rename your own file to something else than uvloop.py, such as test_uvloop.py.

You're confusing Python's import machinery by having your own file the same name as the library you're trying to use.

AKX
  • 152,115
  • 15
  • 115
  • 172
  • This the right answer for question/situation as posed by OP and should be accepted. Leaving my answer up, however, for people who, like me, arrived here by googling the error message. – blahblahetcetc Jan 21 '20 at 20:06