1

so the title pretty much says it all, I couldn't run a project which used elect.poll(), since this is for college, I must use select.poll() and cannot switch it for kqueue, so I read in this post that I could use MacPorts to work around it, so I did and it worked, but apparently after closing that terminal now I can't use it again, it keeps saying: AttributeError: 'module' object has no attribute 'poll'.

I don't understand why it only worked once, I've modified the paths file to have opt/local/bin and opt/local/sbin I have selected the macports version of python, does anyone have an answer? Thank you very much and I will provide any extra information if needed.

Community
  • 1
  • 1

1 Answers1

0

Do you have any file named "select.py", "select.pyc", "select.pyo"? If there are, and you try to "import select", Python would be trying to recursively import that file instead of the standard library.

To solve this, you must rename your script to something else and to make sure you remove any automatically-created .pyc or .pyo files.

Lie Ryan
  • 62,238
  • 13
  • 100
  • 144
  • No I don't, I can't find the answer to my problem anywhere – Jenaro Calviño Jun 14 '16 at 15:29
  • @JenaroCalviño: Are you sure you started the MacPorts version of Python instead of the System Python? What is printed when you run "from sys import executable; print executable". This should point to MacPorts' folder rather than system python. – Lie Ryan Jun 14 '16 at 15:42
  • you are right,the result of the print is: /usr/bin/python, but when I type: `$ port select --list python Available versions for python: none python26-apple python27 (active) python27-apple` – Jenaro Calviño Jun 14 '16 at 15:53
  • @JenaroCalviño: There are [a number of ways](https://stackoverflow.com/questions/8201760/how-to-macports-select-python) to set `python` to launch non-system python. Personally, I don't like disturbing anything that comes with the system, so I would use a virtualenv, e.g. `virtualenv -p /path/to/python envname`. If you use virtualenv, you would need to activate the virtual environment on each new shell instance. – Lie Ryan Jun 14 '16 at 16:19
  • Ok, that's clear now and it works, think you very much – Jenaro Calviño Jun 14 '16 at 17:15