TelegramTools / TLImporter

📲 Telegram Chat Importer: Import chats from WhatsApp or other services into Telegram
GNU Affero General Public License v3.0
127 stars 11 forks source link

RuntimeError while executing TLImporter.cpython-38.opt-2.pyc #12

Closed bhavye9499 closed 4 years ago

bhavye9499 commented 4 years ago

Hi, I am using Ubuntu 18.04, and followed the below mentioned steps-

  1. Downloaded and extracted TLImporter-3.0.4.zip
  2. Downloaded and extracted Source code (zip)
  3. Executed this command- pip install -r requirements.txt
  4. Executed this command- python3 TLImporter.cpython-38.opt-2.pyc

I got this error- RuntimeError: Bad magic number in .pyc file

Did I do something wrong ?

ferferga commented 4 years ago

By the way, is the normal .py file working correctly?

bhavye9499 commented 4 years ago

No,

Upon executing this command - python3 TLImporter.py

I get the following error -
Traceback (most recent call last): File "TLImporter.py", line 29, in api_id = YOUR_API_ID_HERE NameError: name 'YOUR_API_ID_HERE' is not defined

ferferga commented 4 years ago

@bhavye9499 You need to follow the instructions in the "building from source" section of the documentation first

bhavye9499 commented 4 years ago

Hi, Do you mean I should follow instructions from this link? - https://github.com/TelegramTools/TLImporter/wiki/Using-from-sources

ferferga commented 4 years ago

@bhavye9499 Exactly

ferferga commented 4 years ago

@bhavye9499 Tell me if it's successful or you have any other issue please! :D 😁

bhavye9499 commented 4 years ago

Hi, Eventually it worked out perfectly fine. Thank you for making such a great tool :) Now I will recommend it to all my friends :D

I believe there is a small bug in the .py file, because of which it is not accepting the file path if you drag-and-drop a .txt file on the terminal. When you drag-and-drop a .txt file, the path appears to be enclosed between single quotes, however at line 1077 in .py file you are removing the double quotes, because of which single quotes are not removed, and os.path.isfile(FilePath) returns False.

It took me few minutes to figure it out, and after entering the absolute path manually, it worked like a charm. I believe, fixing that small bug would make drag-and-drop robust ! :)

Also I believe that it would be really helpful for Linux users if you mention in README.md that they have to run the .py file instead of the .pyc file, and also mention that they need to change the api_id and api_hash variables in the .py file.

Another suggestion - the current version of this tool imports chats between two users. It would be really great and helpful if it could also import "group chats" that have more than two members.

These are some of my observations and suggestions, hope they help you. Feel free to ignore them if they seem useless.

Once again thanks a lot for making such a wonderful tool. Cheers :D

ferferga commented 4 years ago

@bhavye9499 Hey, sorry for the long time without replying! Completely missed this.

  1. I will check what you say for the next update of TLImporter in an Unix-like system, because in Windows there are no issues at least with the current implementation, if I recall correctly.

  2. In my intentions, the .pyc file is, in fact targeted for Linux/Mac users. I didn't use bytecode files extensively, but they're basically the compiled code of TLImporter. I think that the problem you had might be related to the version of your/my interpreter: I compiled it using Python 3.8.0 and you probably used the Python3 package included in your system's repository, right? That usually is Python 3.6 in Ubuntu 18, for example. It's unlikely it's the latest version available, and I think that, for bytecode files, it's essential that both the compiler and the runtime versions match. About the api_id and api_hash, that's stated in the Readme already, section "Build it yourself"

I will leave this open to remind me about the path issue, however, I hope that everything else is already resolved.

Thank you very much for your feedback and for using this!

ferferga commented 4 years ago

@bhavye9499 Everything commented in this issue has been addressed in TLImporter 3.0.6.

Closing this.