Cannot import anything from six. Both of these lines yield errors:
from six.moves.urllib.request import urlretrieve
--> Unresolved reference "urlretrieve"
from six.moves import cPickle as pickle
--> Unresolved reference "cPickle"
OSX 10.11.5. IntelliJ 2016.1.2, PyCharm 2016.1.3, Python 2.7.11, Six 1.10.0.
What I've done to try to fix (per PyCharm shows unresolved references error for valid code and other posts):
_
$ sudo pip install -U six
Requirement already up-to-date: six in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.10.0-py2.7.egg
Python SDKs I tried:
Python 2.7.11 (/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7)
Python 3.5.1 (/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5)
Python 2.7.10 (/usr/local/bin/python2.7)
Nothing worked. Help would be welcome! Thanks.
---------- Update May 23 2016 -------------------------------
Running the "from six.moves..." import lines from the command line does not yield errors. The command line invokes Python 2.7.11. PyCharm also is using Python 2.7.11, and PyCharm also shows that six is available - see first screen shot. There are no .pyc files in the project, just main.py. Oddly, main.py runs without error within PyCharm; the "Hello" line does print (see second screen shot). This screen shot shows the project interpreter in the settings: I'm still stumped.
---------- Update May 24 2016 -----------------------------
import six
works without error in both the code and the python shell and after execution, six.file = /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/six-1.10.0-py2.7.egg/six.pyc
.
However, the PyCharm IDE still shows the errors in the six.moves import lines.
This question seems to be answered by this one (I don't know how to mark this one as duplicate).
So unfortunately there's no easy solution because of the dynamic nature of the "six" module unless you implement your own python-skeleton for this module (which is not what straithforward).
six
is only installed at /Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
, so it will only work if you use that interpreter in PyCharm/IntelliJ
Note, if you create a new virtual environment, you'll have to install six
in it separately.
If PyCharm/IntelliJ is giving you these warnings, but the code actually runs - then this is just a caching issue with PyCharm and you can safely ignore it - chances are on the next cache rebuild PyCharm will update its cache.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With