3

Stack Trace:

(realestate_env) PS C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction> pipreqs                   
ERROR: Failed on file: C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\Lib\site-packages\black\linegen.py
Traceback (most recent call last):
  File "C:\Users\Jun\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\Jun\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\Scripts\pipreqs.exe\__main__.py", line 7, in <module>
  File "C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\lib\site-packages\pipreqs\pipreqs.py", line 488, in main
    init(args)
  File "C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\lib\site-packages\pipreqs\pipreqs.py", line 415, in init
    candidates = get_all_imports(input_path,
  File "C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\lib\site-packages\pipreqs\pipreqs.py", line 131, in get_all_imports
    raise exc
  File "C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction\realestate_env\lib\site-packages\pipreqs\pipreqs.py", line 117, in get_all_imports
    tree = ast.parse(contents)
  File "C:\Users\Jun\AppData\Local\Programs\Python\Python39\lib\ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 283
    Ø: Set[str] = set()
     ^
SyntaxError: invalid character '˜' (U+02DC)
(realestate_env) PS C:\Users\Jun\Desktop\Jupyter Projects\Real Estate Price Prediction> 

I am having this issue when I am trying to use pipreqs to create a requirement.txt file. I have done an extensive search on the Internet to solve this problem but then hardly found an effective solution until I found the below link: https://blog.csdn.net/Pragmatism_3568/article/details/105414950

From the blog, I know that the issue that I facing is related to the byte-order mark (BOM). However, this is a CSDN forum (can be seemed as a China version of Stack Overflow) where all the things are written in Chinese. So, I couldn't understand how to solve the issue I faced even though I found the solution.

As a Malaysian Chinese, I did learn Mandarin when I was a kid until my graduation in high school, I have no problem in reading, speaking and understanding Chinese but the problem is I learn programming in English, not Chinese and there are many proper nouns written in this blog I couldn't understand. So, anyone who has been studying in China or China users can help with this?

Any other people who know how to tackle this issue are welcome to help to solve this problem.

林抿均
  • 33
  • 7
  • Show your code and the stack trace as *text*, not a picture. [Edit] your question to fix this. We can't run a picture. It is also not certain that the post you found really is the cause of your problem. – BoarGules Feb 11 '22 at 08:20

1 Answers1

2

I was able to solve this issue by specifying the encoding utf-8-sig when executing pipreqs:

pipreqs.exe <path> --encoding=utf-8-sig

see pipreqs usage on pypi for more information. I hope this helps.

JDG
  • 477
  • 5
  • 6
  • I tried this before but I don't know why it doesn't work on my laptop. However, I saw many people find this work, even my friend. – 林抿均 Mar 13 '23 at 11:58