prompt-toolkit / ptpython

A better Python REPL
BSD 3-Clause "New" or "Revised" License
5.19k stars 277 forks source link

Support Python 3.8 #411

Open frankgerhardt opened 3 years ago

frankgerhardt commented 3 years ago

pip install error on Python 3.8:

$ conda activate py38env
(py38env) $ pip install ptpython
Collecting ptpython
  Downloading ptpython-3.0.9-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 1.0 MB/s 
Requirement already satisfied: jedi>=0.16.0 in /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from ptpython) (0.17.2)
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.0 in /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from ptpython) (3.0.10)
Requirement already satisfied: pygments in /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from ptpython) (2.7.3)
Requirement already satisfied: parso<0.8.0,>=0.7.0 in /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from jedi>=0.16.0->ptpython) (0.7.1)
Requirement already satisfied: wcwidth in /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages (from prompt-toolkit<3.1.0,>=3.0.0->ptpython) (0.2.5)
Collecting appdirs
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Collecting black
  Downloading black-20.8b1.tar.gz (1.1 MB)
     |████████████████████████████████| 1.1 MB 1.1 MB/s 
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /home/user/bin/anaconda3/envs/py38env/bin/python /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-m93ze6p7/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=41.0' setuptools-scm wheel                                                                                  
       cwd: None                                                                                            
  Complete output (31 lines):                                                                               
  Traceback (most recent call last):                                                                        
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/runpy.py", line 194, in _run_module_as_main  
      return _run_code(code, main_globals, None,                                                            
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/runpy.py", line 87, in _run_code             
      exec(code, run_globals)                                                                               
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/__main__.py", line 26, in <module>                                                                                                     
      sys.exit(_main())                                                                                     
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/cli/main.py", line 73, in main                                                                                               
      command = create_command(cmd_name, isolated=("--isolated" in cmd_args))                               
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/commands/__init__.py", line 105, in create_command                                                                           
      module = importlib.import_module(module_path)                                                         
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/importlib/__init__.py", line 127, in import_module                                                                                                       
      return _bootstrap._gcd_import(name[level:], package, level)                                           
    File "<frozen importlib._bootstrap>", line 1014, in _gcd_import                                         
    File "<frozen importlib._bootstrap>", line 991, in _find_and_load                                       
    File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked                              
    File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 783, in exec_module
    File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/commands/install.py", line 17, in <module>
      from pip._internal.cli.req_command import RequirementCommand, with_cleanup
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/cli/req_command.py", line 23, in <module>
      from pip._internal.req.constructors import (
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/req/__init__.py", line 10, in <module>
      from .req_install import InstallRequirement
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip/_internal/req/req_install.py", line 10, in <module>
      import uuid
    File "/home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/uuid.py", line 138
      if not 0 <= time_low < 1<<32L:
                                  ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command errored out with exit status 1: /home/user/bin/anaconda3/envs/py38env/bin/python /home/user/bin/anaconda3/envs/py38env/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-m93ze6p7/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple -- 'setuptools>=41.0' setuptools-scm wheel Check the logs for full command output.
jonathanslenders commented 3 years ago

I think the issue is elsewhere. Python 3.8 and 3.9 are supported.

frankgerhardt commented 3 years ago

Only 3.7 is mentioned in the README:

Ptpython is an advanced Python REPL. It should work on all Python versions from 2.6 up to 3.7 and work cross platform (Linux, BSD, OS X and Windows).

bastiaan85 commented 3 years ago

This stems from manually installing uuid using pip (or conda), as there's still a package on Pypi dating back from 2007. Which will then naturally lead to syntax errors or similar issues. Instead remove that package using pip/conda and it will instead use the uuid module that's part of Python's standard library.

Freed-Wu commented 3 years ago

In pypi, Screenshot from 2021-09-18 21-55-48

However, it support python 3.9 by pip install git+https://github.com/prompt-toolkit/ptpython, not pip install ptpython

bastiaan85 commented 3 years ago

On my macos 11.4 machine it installs natively with pip in 3.9:

~ % python3.9 -m pip install ptpython
Collecting ptpython
  Downloading ptpython-3.0.20-py2.py3-none-any.whl (61 kB)
     |████████████████████████████████| 61 kB 409 kB/s
Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.18 in /opt/homebrew/lib/python3.9/site-packages (from ptpython) (3.0.18)
Requirement already satisfied: appdirs in /opt/homebrew/lib/python3.9/site-packages (from ptpython) (1.4.4)
Requirement already satisfied: pygments in /opt/homebrew/lib/python3.9/site-packages (from ptpython) (2.8.1)
Requirement already satisfied: jedi>=0.16.0 in /opt/homebrew/lib/python3.9/site-packages (from ptpython) (0.18.0)
Requirement already satisfied: parso<0.9.0,>=0.8.0 in /opt/homebrew/lib/python3.9/site-packages (from jedi>=0.16.0->ptpython) (0.8.2)
Requirement already satisfied: wcwidth in /opt/homebrew/lib/python3.9/site-packages (from prompt-toolkit<3.1.0,>=3.0.18->ptpython) (0.2.5)
Installing collected packages: ptpython
Successfully installed ptpython-3.0.20
WARNING: You are using pip version 21.1.1; however, version 21.2.4 is available.
You should consider upgrading via the '/opt/homebrew/opt/python@3.9/bin/python3.9 -m pip install --upgrade pip' command.

Like I mentioned above OP's issue is that he installed uuid from pip for some reason, which will cause errors when imported by other libraries.

adigitoleo commented 6 months ago

Again the README is out of date, it says 3.9 but the CI is running on 3.11