sys_platform is not defined x64 Windows - python

This has been bugging me for a little while. I recently upgraded to x64 Python, and I started getting this error (example pip install).
C:\Users\<uname>\distribute-0.6.35>pip install python-qt
Collecting python-qt
Downloading python-qt-0.50.tar.gz
Building wheels for collected packages: python-qt
Running setup.py bdist_wheel for python-qt
Complete output from command C:\Python27\python.exe -c "import setuptools;__file__='c:\\users\\<uname>\\appdata\\local\\t
emp\\pip-build-vonat7\\python-qt\\setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" bd
ist_wheel -d c:\users\<uname>\appdata\local\temp\tmpghy5gtpip-wheel-:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\<uname>\appdata\local\temp\pip-build-vonat7\python-qt\setup.py", line 11, in <module>
packages=['Qt'],
File "C:\Python27\lib\distutils\core.py", line 137, in setup
ok = dist.parse_command_line()
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 232, in parse_command_line
result = _Distribution.parse_command_line(self)
File "C:\Python27\lib\distutils\dist.py", line 467, in parse_command_line
args = self._parse_command_opts(parser, args)
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 558, in _parse_command_opts
nargs = _Distribution._parse_command_opts(self, parser, args)
File "C:\Python27\lib\distutils\dist.py", line 523, in _parse_command_opts
cmd_class = self.get_command_class(command)
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\setuptools\dist.py", line 362, in get_command_class
ep.require(installer=self.fetch_build_egg)
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2027, in require
working_set.resolve(self.dist.requires(self.extras),env,installer))
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2237, in requires
dm = self._dep_map
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2466, in _dep_map
self.__dep_map = self._compute_dependencies()
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2499, in _compute_dependencies
common = frozenset(reqs_for_extra(None))
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\pkg_resources.py", line 2496, in reqs_for_extra
if req.marker_fn(override={'extra':extra}):
File "C:\Python27\lib\site-packages\distribute-0.6.35-py2.7.egg\_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 python-qt
Failed to build python-qt
Installing collected packages: python-qt
Running setup.py install for python-qt
Successfully installed python-qt-0.50
The package was installed fine, but I cannot build wheels. I tried re-installing distribute manually by downloading a zip and running python setup.py install. That installed wonderfuly, without a hitch. But I still have the above problem.
How can I re-define sys_platform?
Alright, I rolled back to x86 good ole 32 bit Python, and I still have the problem. This is really concerning, because I cannot reset this after re-installing. I looked at markerlib, which looks promising, but I don't know how to use it safely. Currently I am unable to install pretty much anything from PyPI, so I am giving points to increase interest.
Any help? I really want to be able to use PyPI again.
I chose the selected answer as it is the most likely to solve the problem. I myself have moved back to x86 Python, so I cannot test this myself. Therefore, I encourage future visitors to try this answer, but I have not myself been able to test it.

Might be a bug. Check out: https://bugs.python.org/
You can manually check the markers.py file and try to fix it. I think there would a reference to sys_platform that has to be changed to sys.platform
Regarding markerlib, you can try this out-
import markerlib
marker = markerlib.compile("sys.platform == 'win32'")
marker(environment=markerlib.default_environment(), override={'sys.platform':'win32'})

To fix this error, I found that installing the 0.7.3 version of distribute fixed this. I had also upgraded setuptools and pip along the way (so they may be needed as well), but after upgrading distribute this error finally went away.

Try removing pip and distribute and setuptools, and then manually install pip using get-pip.py .
Then , download setuptools from here , extract -> go inside the extracted folder in command prompt and do python setup.py install
Then , download distribute from here , extract -> go inside the extracted folder in command prompt and do python setup.py install

I ran into this issue today myself, though on OSX. I had run --upgrade as well as trying to uninstall and reinstall it completely.
Eventually, though I went into my site packages, and saw a "correct" version of setuptools (18.1) AS WELL as an older lingering version of it (completely separate version 15.1 of it). Removing it all and reinstalling setuptools fresh fixed it for me.
Hopefully this helps someone else!

I had an old verison of distribute, which didn't correctly resolve dependencies. It was fixed with
C:\Users\cshucks>pip install --upgrade distribute
Collecting distribute
Downloading distribute-0.7.3.zip (145kB)
100% |################################| 147kB 375kB/s
Collecting setuptools>=0.7 (from distribute)
Downloading setuptools-19.2-py2.py3-none-any.whl (463kB)
100% |################################| 466kB 440kB/s
Installing collected packages: setuptools, distribute
Found existing installation: setuptools 16.0
Uninstalling setuptools-16.0:
Successfully uninstalled setuptools-16.0
Found existing installation: distribute 0.6.49
Uninstalling distribute-0.6.49:
Successfully uninstalled distribute-0.6.49
Running setup.py install for distribute
Successfully installed distribute-0.7.3 setuptools-19.2

Related

Some python packages are not installed with docker but others are

TL/DR
I had a horrible puzzle to solve that didn't seem to be tackled anywhere in the web, so now I'm posting it here in case anybody else has the same trouble. Is is already solved, see my answer below.
It was related to pip install, not installing those packages that missed a wheel file.
Long explanation.
When running docker-compose up everything seemed to work like a charm in the building images stage, no errors reported... until the containers where started... then I got some weird errors like this one:
##Traceback (most recent call last):
File "/usr/local/bin/flask", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.7/dist-packages/flask/cli.py", line 894, in main
cli.main(args=args, prog_name=name)
File "/usr/local/lib/python3.7/dist-packages/flask/cli.py", line 557, in main
return super(FlaskGroup, self).main(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1132, in invoke
cmd_name, cmd, args = self.resolve_command(ctx, args)
File "/usr/local/lib/python3.7/dist-packages/click/core.py", line 1171, in resolve_command
cmd = self.get_command(ctx, cmd_name)
File "/usr/local/lib/python3.7/dist-packages/flask/cli.py", line 500, in get_command
self._load_plugin_commands()
File "/usr/local/lib/python3.7/dist-packages/flask/cli.py", line 496, in _load_plugin_commands
self.add_command(ep.load(), ep.name)
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/_init_.py", line 2464, in load
self.require(*args, **kwargs)
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/_init_.py", line 2487, in require
items = working_set.resolve(reqs, env, installer, extras=self.extras)
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/_init_.py", line 777, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'alembic>=0.6' distribution was not found and is required by the application
It seemed that many packages were missing even though I didn't run into any errors when docker was installing them.
And more weird: when entering the container with docker run --rm -it --entrypoint bash <service-name> I could manually install all missing packages using pip3 install -r /var/www/webapp/requirements.txt.lock with no problem. And all errors would be gone. This is the exact same command that my Dockerfile uses in order to install python packages when building it's image.
We had no clue on:
Why this was happening now, since it worked until at least a couple
of weeks ago for the last 2 years!
Why did dockerfile fail but manually running exactly the same command worked.
Why only certain packages were missing, and no errors were raised for them.
How to fix this.
I started my research, took many hours but to summarize:
It seemed that the missing packages didn't have a wheel file in their pypi repository. So pip was falling into "legacy" direct installation but only for those packages, that's why the others were installed properly.
I found that many of these missing packages, like alembic, do have a .whl file but in later versions, not the one we were using: 0.9.9.
It seems that the package Wheel is needed to build a .whl file for those packages that do not include them in their pypi repository. But doing a pip list inside the container showed that wheel was indeed already installed...
I tried manually deleting the wheel package, and running pip3 install -r /var/www/webapp/requirements.txt.lock again... voilá, the same errors that docker reported. the packages without a wheel file were not installed. So I found out that wheel package:
has two different roles:
1- A setuptools extension for building wheels that provides the
bdist_wheel setuptools command
2- A command line tool for working with wheel files
From those 2, the first point seemed to be what was missing from happening.
5. Long story short, in my dockerfile, before installing the requirements, I installed wheel, problem solved.
But why did this happen now and not before??
I found that even if docker didn’t install wheel before running the pip install, it did have setuptools. I don’t exactly know how those two packages work, and less I understand how they cowork to get things done. But searching on setuptools changelog I found that it is updated quite frequently, almost daily.
More interesting, version v60.4.0 of 08 Jan 2022 seemed to be pretty big for the standard of the others, and it includes this as one of the changes:
#2968: Removed tmp_src test fixture. Previously this fixture was copying all the files and folders under the project root, including
the .git directory, which is error prone and increases testing time.
Since tmp_src was used to populate virtual environments (installing
the version of setuptools under test via the source tree), it was
replaced by the new setuptools_sdist and setuptools_wheel fixtures
(that are build only once per session testing and can be shared
between all the workers for read-only usage).
Not sure, but maybe it did change sth related to how packages without a wheel file were installed and now it wouldn't work without package Wheel doing it.

Unable to install Rasa 1.7.0 on Windows 10

I have been trying to install rasa on my Window 10 machine. But no success so far. Environment wise I have python 3.7, pip 20.3. When I give pip install rasa==1.7.0 on anaconda powershell it takes ages to download the dependencies and finally errors out as:
ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_internal\cli\base_command.py", line 224, in _main
status = self.run(options, args)
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_internal\cli\req_command.py", line 180, in wrapper
return func(self, options, args)
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_internal\commands\install.py", line 321, in run
reqs, check_supported_wheels=not options.target_dir
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 122, in resolve
requirements, max_rounds=try_to_avoid_resolution_too_deep,
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 445, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 325, in resolve
for item in self.state.criteria.items()
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 326, in <listcomp>
if not self._is_current_pin_satisfying(*item)
File "C:\Users\user\Anaconda3\envs\py37\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 193, in _is_current_pin_satisfying
for r in criterion.iter_requirement()
AttributeError: 'NoneType' object has no attribute 'iter_requirement'
I could not find much details on this. As already dependencies were taking lot of time, I came across New resolver takes time article which states pip 20.3 takes more time. One way to solve it is to give exact versions of dependencies which I was not sure of as am quite new to rasa. I tried using older resolver as pip install rasa==1.7.0 --use-deprecated=legacy-resolver. After sometime it errored out as below:
ERROR: Could not find a version that satisfies the requirement jaxlib>=0.1.51 (from dopamine-rl->tensor2tensor~=1.14.0->rasa==1.7.0) (from versions: none)
ERROR: No matching distribution found for jaxlib>=0.1.51 (from dopamine-rl->tensor2tensor~=1.14.0->rasa==1.7.0)
To resolve this: I did dopamine install of different version as suggested here as I was not sure what version to go with. The packages started downloading and finally gave the dependency conflict error, occurred due to usage of legacy resolver.
ERROR: pip's legacy dependency resolver does not consider dependency conflicts when selecting packages. This behaviour is the source of the following dependency conflicts.
tensorflow-metadata 0.26.0 requires absl-py<0.11,>=0.9, but you'll have absl-py 0.11.0 which is incompatible.
kfac 0.2.3 requires tensorflow-probability==0.8, but you'll have tensorflow-probability 0.7.0 which is incompatible.
If we go with new resolver then it takes lot of time in resolving dependencies. Also we are not sure what all dependency versions needs to be downloaded to fine tune it.
Any help pointers here would be much appreciated.
UPDATE
I tied the following command sequence:
pip install dopamine-rl==3.0.1
pip install absl-py>=0.9
pip install rasa==1.7.0 --use-deprecated=legacy-resolver
Rasa got installed. Installed tensor-flow after this as conda install tensorflow==1.15.0. Now when tried to check tensorflow version, got the below warning and error.
The TensorFlow Distributions library has moved to TensorFlow Probability (https://github.com/tensorflow/probability). You should update all references to use `tfp.distributions` instead of `tf.distributions`.
ImportError: cannot import name 'Layer' from 'tensorflow.python.keras.engine.base_layer' (C:\Users\user\Anaconda3\envs\py37\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py)
I see you already started a discussion on Rasa Forum, let's move the conversation there! :) https://forum.rasa.com/t/unable-to-install-rasa-1-7-0/38313

PyCluster unable to install package

This is the error I am getting when trying to install PyCluster. I am using python 2.7 with anaconda in spyder IDE and on windows.
Downloading/unpacking PyCluster
Getting page http://pypi.python.org/simple/PyCluster
URLs to search for versions for PyCluster:
* httpss://pypi.python.org/simple/PyCluster/
Getting page httpss://pypi.python.org/simple/PyCluster/
Analyzing links from page httpss://pypi.python.org/simple/pycluster/
Could not find any downloads that satisfy the requirement PyCluster
No distributions at all found for PyCluster
Exception information:
Traceback (most recent call last):
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\basecommand.py", line 107, in main
status = self.run(options, args)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\commands\install.py", line 256, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\req.py", line 1011, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "C:\Users\anankuma\AppData\Local\Continuum\Anaconda\lib\site-packages\pip-1.2.1-py2.7.egg\pip\index.py", line 157, in find_requirement
raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for PyCluster
Please suggest a workaround. Thanks
here is the package there is no source or binary available to download.
a module (pyclustering) with similar name.
The Python Package Index (PYPI) is a repository of software for the Python programming language.
One can download packages manually or using pip install
One can upload binary and source packages as well.
For example this package has a source and some binaries as well
Python Wheels and Python Eggs are ease to install, mostly used on windows.
However manual install can be done using MS Windows installer files downloaded directly form PYPI
Had a similar situation installing this Pycluster package
pip was trying to build the package because there were no official wheels
for Python 3.5 & windows.
Solved it by downloading an unofficial wheel from here:
https://www.lfd.uci.edu/~gohlke/pythonlibs/#pycluster
There are many wheel files on this website.
Try different versions to see whichever works the best for you.
You can install the .whl file this way using Anaconda Prompt with the following code
pip install Pycluster-1.56-cp36-cp36m-win_amd64.whl
install with pip:
pip3 install pyclustering
it even works with Anaconda prompt

installing ggplot for python on windows10 64

I am using python 2.7 and installed the anaconda installations too.
although I am novice user, but everything is working fine.
Then I decided to use the ggplot. (yhat package for python)
instructions says
pip install -U ggplot
I had problem that it started to install many packages including ggplot but then it halt during the statsmodels package giving the following message:
c:\Python27\Scripts>pip install -U ggplot
Collecting ggplot
Using cached ggplot-0.6.8.tar.gz
Requirement already up-to-date: six in c:\python27\lib\site-packages (from ggplot)
Collecting statsmodels (from ggplot)
Using cached statsmodels-0.6.1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 20, in <module>
File "c:\users\appdata\local\temp\pip-build-8ce3lv\statsmodels\setup.py", line 393, in <module>
install_requires) = check_dependency_versions(min_versions)
File "c:\users\appdata\local\temp\pip-build-8ce3lv\statsmodels\setup.py", line 119, in check_dependency_versions
if not (StrictVersion(strip_rc(npversion)) >= min_versions['numpy']):
File "C:\Python27\lib\distutils\version.py", line 40, in __init__
self.parse(vstring)
File "C:\Python27\lib\distutils\version.py", line 107, in parse
raise ValueError, "invalid version number '%s'" % vstring
ValueError: invalid version number '1.10.0.post2'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\appdata\local\temp\pip-build-8ce3lv\statsmodels
I read in SO and on gitHub many questions but nothing is clear except that it is versioning problem
I tried to upgrade the packages but I failed.
any help is appreciated.
use conda install statsmodels. works for me on Windows 10 64bit
numpy 1.10 will soon be available without the post in the version number, based on the discussion on the numpy mailing list and numpy issue tracker.
The version scanning of statsmodels cannot handle the post part since it has never been used in the past by any science or data analysis related package.
The only solution right now is to edit the setup.py of statsmodels, or switch to a numpy version that doesn't have the post version number, or edit the version number in numpy.
https://github.com/statsmodels/statsmodels/issues/2645
https://github.com/numpy/numpy/issues/6431

python - easy_install stops working after distribute upgrade

When trying to install a package easy_install asked me to upgrade distribute:
The required version of distribute (>=0.6.35) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
This seemed to work fine:
$ easy_install -U distribute
Searching for distribute
Reading http://pypi.python.org/simple/distribute/
Best match: distribute 0.7.3
Processing distribute-0.7.3-py2.7.egg
Removing distribute 0.6.28 from easy-install.pth file
Adding distribute 0.7.3 to easy-install.pth file
Using /xxx/software/lib/python2.7/site-packages/distribute-0.7.3-py2.7.egg
Processing dependencies for distribute
Finished processing dependencies for distribute
But now when I start easy_install I get this:
$ easy_install
Traceback (most recent call last):
File "/xx/software/bin/easy_install", line 9, in <module>
load_entry_point('distribute', 'console_scripts', 'easy_install')()
File "/xx/software/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg/pkg_resources.py", line 357, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/xx/software/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg/pkg_resources.py", line 2393, in load_entry_point
raise ImportError("Entry point %r not found" % ((group,name),))
ImportError: Entry point ('console_scripts', 'easy_install') not found
What happened? How do I fix this
Try updating your setup tools manually.
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
sudo python ez_setup.py --user
Following an answer on a different question about pip vs. easy_install, you can uninstall a package that was installed with easy_install using pip:
sudo pip uninstall distribute
This removed the offending version of distribute, and easy_install works again.
I had same problem, then i found that there is easy_install-2.7 and I can install packages properly.

Categories