Pip: NameError: name 'sys_platform' is not defined

Created on 26 Jun 2015  路  19Comments  路  Source: pypa/pip

I'm getting lots of errors like this when installing packages recently. I am on pip 7.0.3

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/private/var/folders/nh/1d2kqct94cv5144g627_yty40000gn/T/pip-build-i4Snhb/contextdecorator/setup.py", line 56, in <module>
      classifiers=CLASSIFIERS,
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 137, in setup
      ok = dist.parse_command_line()
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/setuptools/dist.py", line 276, in parse_command_line
      result = _Distribution.parse_command_line(self)
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 467, in parse_command_line
      args = self._parse_command_opts(parser, args)
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/setuptools/dist.py", line 602, in _parse_command_opts
      nargs = _Distribution._parse_command_opts(self, parser, args)
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 523, in _parse_command_opts
      cmd_class = self.get_command_class(command)
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/setuptools/dist.py", line 406, in get_command_class
      ep.require(installer=self.fetch_build_egg)
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/pkg_resources.py", line 2272, in require
      working_set.resolve(self.dist.requires(self.extras),env,installer)))
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/pkg_resources.py", line 2489, in requires
      dm = self._dep_map
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/pkg_resources.py", line 2700, in _dep_map
      self.__dep_map = self._compute_dependencies()
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/pkg_resources.py", line 2733, in _compute_dependencies
      common = frozenset(reqs_for_extra(None))
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/pkg_resources.py", line 2730, in reqs_for_extra
      if req.marker_fn(override={'extra':extra}):
    File "/Users/paul/.virtualenvs/anentropic/lib/python2.7/site-packages/_markerlib/markers.py", line 109, in marker_fn
      return eval(compiled_marker, environment)
    File "<environment marker>", line 1, in <module>
  NameError: name 'sys_platform' is not defined

  ----------------------------------------
  Failed building wheel for contextdecorator
auto-locked

Most helpful comment

Same issue here.
pip install --upgrade distribute fixed it.

All 19 comments

+1

hi @andrecp ! :)

...for some reason it is specific to our project's virtualenv, doesn't happen to me in other envs

Hmm, I am having this same problem when running on travis ci, I got in touch with their support and seems to have something to do with the pip / setup tools versions.

For example:

  • "pip install -U pip"
  • "pip install setuptools==0.8"

gives me the problem

  • pip install --upgrade setuptools
  • pip install --upgrade pip

doesn't.

looks like it's time to delete setuptools==0.8 from requirements-test.txt ... :)

yup, just gotta do some testing to see if it doesn't break anything! :)

@andrecp @anentropic Do you still consider this a bug in pip?

it looks more like a bug in setuptools==0.8

@dstufft seems like this can be closed.

Going to close this as a bug in setuptools 0.8 that is no longer very important.

fwiw, I had the same issue and needed to upgrade distribute to get it working.

distribute is no longer relevant as it was superseeded by setuptools ages ago

I am aware of this. I could not get it to work without upgrading distribute however. Even though I don't use distribute anywhere. I ran into the "sys_platform" error. Upgrading setuptools did not change that. I saw references to distribute in the stack-trace, and after upgrading it, it did work.

I am currently running on Ubuntu 12.04.5 LTS which is quite ancient in itself. Maybe that has something to do with it?

even in Ubuntu 15.10 (upgraded from 14.04) i still needed to upgrade distribute to get it to work as well, thanks for the tip/fix.

I just had the same issue on Windows x32. pip install --upgrade distribute did fix it. Thanks for the tips.

I was trying to install virtualenv when i ran across this problem. Thanks to the help on here i came up with:

sudo -H pip install --upgrade setuptools
sudo -H pip install --upgrade pip
sudo -H virtualenv venv

Had the same error.

But since it looked like the error was generated when pip is trying to build a wheel cache, I tried disabling that by adding the --no-cache-dir to the pip install .. and it worked for me.

Sounds like a better and sensible solution to me than upgrading setuptools etc. Regarding the error itself - Not sure what / why exactly pip is complaining about .. but I think that pip should be handling this better.

@mohanraj-r 's comment worked for me as well. This server is using a pretty ancient version of pip / python, so it COULD be that, but doing "pip install lxml --user" didnt work, but "pip install lxml --user --no-cache-dir" worked.

Same issue here.
pip install --upgrade distribute fixed it.

I am getting this error with sudo -H pip install pyublas --no-cache-dir on a brand new install of Ubuntu 16.04. I've tried all of the suggestions here with no luck. Thanks.

Was this page helpful?
0 / 5 - 0 ratings