Unable to import 'os' (import-error)
Hello: I am trying to run a simple 2-line Python script through pylint on Ubuntu without success (see https://github.com/PyCQA/pylint/issues/1305). Following are the details. Does anyone know what step I am missing? Steps to reproduce $ cat li.py #!/usr/bin/env python """foobar""" import os print os.listdir(os.curdir) $ pylint --reports=n li.py ************* Module li F: 3, 0: Unable to import 'os' (import-error) $ which python /usr/bin/python $ python --version Python 2.7.6 $ ls /usr/lib/python2.7/os.py /usr/lib/python2.7/os.py $ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS" Current behavior pylint reports an import error Expected behavior No errors should be reported by pylint pylint --version output $ pylint --version pylint 1.1.0, astroid 1.0.1, common 0.61.0 Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] @bdurant Thank you, Bill
That's a pretty old pylint. Maybe update it? Is pylint fully or partially installed? What does "which pylint" say? -- Dan Stromberg
Hello Dan: pylint is fully installed. Even with the latest pylint the issue still happens: $ cat li.py #!/usr/bin/env python """foobar""" import os print os.listdir(os.curdir) $ /usr/local/bin//pylint --version pylint 1.6.5, astroid 1.4.9 Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4] $ /usr/local/bin/pylint --reports=n li.py ************* Module li E: 3, 0: Unable to import 'os' (import-error) What am I missing? Thank you! Bill On 01/30/2017 07:01 PM, Dan Stromberg wrote:
That's a pretty old pylint. Maybe update it?
Is pylint fully or partially installed?
What does "which pylint" say?
-- Dan Stromberg
Hello All: A new data point... I am seeing the issue only on Ubuntu 14.04. It works fine on Redhat Enterprise Linux Server 6.6. So it looks like pylint is broken on Ubuntu. Is there a workaround/fix for Ubuntu 14.04? Regards, Bill On 1/31/2017 8:29 AM, Bill D wrote:
Hello Dan:
pylint is fully installed.
Even with the latest pylint the issue still happens:
$ cat li.py #!/usr/bin/env python """foobar""" import os print os.listdir(os.curdir)
$ /usr/local/bin//pylint --version pylint 1.6.5, astroid 1.4.9 Python 2.7.6 (default, Oct 26 2016, 20:30:19) [GCC 4.8.4]
$ /usr/local/bin/pylint --reports=n li.py ************* Module li E: 3, 0: Unable to import 'os' (import-error)
What am I missing?
Thank you!
Bill
On 01/30/2017 07:01 PM, Dan Stromberg wrote:
That's a pretty old pylint. Maybe update it?
Is pylint fully or partially installed?
What does "which pylint" say?
-- Dan Stromberg
On Jan 31, 2017, at 08:29 AM, Bill D wrote:
$ cat li.py #!/usr/bin/env python ^^^^^^^^^^^^^^^^^^^^^^ """foobar""" import os print os.listdir(os.curdir)
$ /usr/local/bin//pylint --version ^^^^^^^^^^^^^^^^^^^^^^^^^
It could be you're mixing up your Python interpreter and runtimes. E.g. running a different 'python' than /usr/bin/python because it's earlier on your $PATH, or picking up some misconfigured /usr/local/bin/python that doesn't have its stdlib installed correctly. Try narrowing it down with only packages from the Ubuntu archive. Cheers, -Barry
* Bill D <littus@icloud.com>, 2017-01-30, 17:06:
$ pylint --reports=n li.py ************* Module li F: 3, 0: Unable to import 'os' (import-error)
Very odd. FWIW, I can't reproduce it in a clean Trusty environment. I get: $ pylint --reports=n li.py No config file found, using default configuration $ echo $? 0 -- Jakub Wilk
Hello Jakub: To fix your issue just do a 'touch ~/pylintrc' Regards, Bill On 1/31/2017 2:44 AM, Jakub Wilk wrote:
* Bill D <littus@icloud.com>, 2017-01-30, 17:06:
$ pylint --reports=n li.py ************* Module li F: 3, 0: Unable to import 'os' (import-error)
Very odd. FWIW, I can't reproduce it in a clean Trusty environment. I get:
$ pylint --reports=n li.py No config file found, using default configuration
$ echo $? 0
participants (4)
-
Barry Warsaw
-
Bill D
-
Dan Stromberg
-
Jakub Wilk