2

On my Python 3.6 installation, I just tried

pip install nipet

but I get this:

Complete output from command python setup.py egg_info:
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\me\AppData\Local\Temp\pip-install-eef9zqvc\nipet\setup.py", line 64
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('e> the current operating system is not supported.')?

This is most probably related to nipet targeting Python 2.x.

I have successfully tried 2to3 on some part of this package, and noticed that all incompatibilities come down to print statements. However, since it is setup.py which fails, I cannot even install all the files in their proper location to run 2to3 on.

Is there some kind of pip wrapper for 2to3that would allow me to install a Python 2.x package without much manual effort?

3
  • 3
    You should probably not try to patch a library while installing it. Check out the source code from the official repository, make it Python 3 compatible, check it back in. Sometimes it's trivial to port a package to Python 3, but usually it's a bit more work than just running 2to3 on it. Commented Dec 4, 2018 at 13:19
  • what if you do something like pip3 install ... and install the python 3 version (if exists)? Sometimes there are two python versions running Commented Dec 4, 2018 at 13:19
  • @ggdx pip3 install nipet results in the same error. Commented Dec 4, 2018 at 13:22

2 Answers 2

4

TL; DR: No, you can't.


nipet is not Python 3 compatible. As @deceze said in comment, you need to fix that before trying to install it. pip can't do the job.

Checkout the code and make it Python 3 (this may involve 2to3 and probably manual changes). Then retry to install it. If you're happy with what you got, you may submit your Python 3 port to the maintainer.

Also, nipet should be fixed to specify it is Python 2 only so that it is listed as Python 2 only on PyPI and pip3 does not even attempt to install if. You should open an issue in the bugtracker to ask the maintainer to fix that. Or even send a pull-request adding appropriate classifiers to setup.py, If you're comfortable doing that.

Sign up to request clarification or add additional context in comments.

Comments

1

While it is true what @Jérôme writes, this is not true for all components. For the sake of completeness, I would like to mention the use_2to3 option of setuptools, which do most of what I wanted. (They do not touch setup.py, though, it seems).

Here is some more information:

Setuptools provides a facility to invoke 2to3 on the code as a part of the build process, by setting the keyword parameter use_2to3 to True, but the Setuptools project strongly recommends instead developing a unified codebase using six, future, or another compatibility library.

https://setuptools.readthedocs.io/en/latest/python3.html

1 Comment

+1 for completeness. But in practice, I wouldn't rely on that as a user. Developers might rely on it assuming they ensure it works on their codebase and the result works correctly. Even then, it is definitely not the recommended way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.