Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows line endings of pyc file detected on Ubuntu #84173

Closed
vladinko0 mannequin opened this issue Mar 17, 2020 · 2 comments
Closed

Windows line endings of pyc file detected on Ubuntu #84173

vladinko0 mannequin opened this issue Mar 17, 2020 · 2 comments
Labels
3.7 (EOL) end of life

Comments

@vladinko0
Copy link
Mannequin

vladinko0 mannequin commented Mar 17, 2020

BPO 39992
Nosy @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2020-03-17.12:26:59.894>
created_at = <Date 2020-03-17.12:09:46.569>
labels = ['3.7']
title = 'Windows line endings of pyc file detected on Ubuntu'
updated_at = <Date 2020-03-17.12:26:59.893>
user = 'https://bugs.python.org/vladinko0'

bugs.python.org fields:

activity = <Date 2020-03-17.12:26:59.893>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = True
closed_date = <Date 2020-03-17.12:26:59.894>
closer = 'serhiy.storchaka'
components = []
creation = <Date 2020-03-17.12:09:46.569>
creator = 'vladinko0'
dependencies = []
files = []
hgrepos = []
issue_num = 39992
keywords = []
message_count = 2.0
messages = ['364417', '364419']
nosy_count = 2.0
nosy_names = ['serhiy.storchaka', 'vladinko0']
pr_nums = []
priority = 'normal'
resolution = 'third party'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue39992'
versions = ['Python 3.7']

@vladinko0
Copy link
Mannequin Author

vladinko0 mannequin commented Mar 17, 2020

I have problem to run pyc file on one machine with Ubuntu Server 18.04.4 LTS.

This is my source code of the file:

#!/root/PycharmProjects/Project/venv/bin/python3.7
print("Hi")

When I compile it in python console with commands:

import py_compile
py_compile.compile('test2.py')

I get test2.cpython-37.pyc file. Then I add execution access by

chmod +x test2.cpython-37.pyc

If I run

./test2.cpython-37.pyc

on first machine (Ubuntu Server 18.04.4 LTS) I get simple "Hi".

But if I run similarly compiled file on other machine with the same OS - Ubuntu Server 18.04.4 LTS, I get:

./test2.cpython-37.pyc: line 1: $'B\r\r': command not found
./test2.cpython-37.pyc: line 2: syntax error near unexpected token )' ./test2.cpython-37.pyc: line 2: z�p^=�@s
ed�dS)ZHiN)�print�rrtest2.py�'

It looks like it is reading Windows line endings. But why? It is created, compiled and run on Ubuntu machine.

How can I solve this issue, and run this pyc file with the right result on second machine?

@vladinko0 vladinko0 mannequin added 3.7 (EOL) end of life labels Mar 17, 2020
@serhiy-storchaka
Copy link
Member

pyc files are not executable files. If you can run it on your machine it means that you have installed some loader hook which allow you to run files which are not machine executable files and not shell scripts. It seems it is not installed on your other machine. This hook is not a part of Python. You have to find what additional software is installed on your first machine and install the necessary parts on your other machine.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.7 (EOL) end of life
Projects
None yet
Development

No branches or pull requests

1 participant