8080labs / pyforest

pyforest - feel the bliss of automated imports
https://8080labs.com
MIT License
1.11k stars 196 forks source link

After using pyforest the console keep output "<IPython.core.display.Javascript object>" #30

Closed woshichuanqilz closed 5 months ago

woshichuanqilz commented 4 years ago

pyforest keep output

Description of Issue

my User import file

# Add your imports here, line by line
# e.g

import datetime
from aip import AipOcr
from aip import AipSpeech
import pandas as pd
from pathlib import Path
import re
import math
import lizhelib
import wave
import struct
import pyaudio
from PIL import Image
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import QEvent, Qt, pyqtSlot
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QApplication, QWidget, QHBoxLayout, QLineEdit, QLabel
from PyQt5.QtWidgets import QMainWindow, QApplication, QWidget, QPushButton, QAction, QLineEdit, QMessageBox
from colour import Color

import speech_recognition as sr
from fuzzyfinder import fuzzyfinder
from io import BytesIO
import lizhelib.win_operation
from lxml import html
from os import path
from scrapy import Selector

from scrapy.cmdline import execute
from selenium import webdriver
import PySimpleGUI as sg
import futures
import glob
import importlib
import inspect
import json
import os
import pandas as pd
import pyautogui
import random
import re
import requests
import scrapy
import shutil
import subprocess
import sys
import tempfile
import threading
import time
import win32clipboard
import wptools
import zipfile

Keep print IPython,

image

Even I make a simple script like this still get the error.

image

Reproduction Steps

  1. Write some simple code.
  2. Import pyforest
  3. then Keep print Ipython ...

What steps have you taken to resolve this already?

I try to delete some package in the user import file. I just leave 1 package in it which is time package

And my script is just like the code in the pic above Simple loop print, But the repeated IPython things print still happen.

How to solve it ?

Anything else?

...

8080labs commented 4 years ago

Hi, thank you for the report and all the details. This made it easy to help you :)

Please note the following:

  1. pyforest is currently only supposed to run in Jupyter Notebook/Lab. This is also the reason why you see the Display.Javascript error. This error might be suppressed via adding a flag that it is not running in Jupyter. eg via adding a new method "pyforest.deactivate_javascript()" If this method is called, a flag will be toggled that suppresses the js
  2. I saw that you imported "from pyforest import *" This is the old way. In version 1.0.0 we changed this to "import pyforest"
  3. Nice to see that you are using a custom imports script. Please note that you can only import one name per line. Eg "from PyQt5.QtCore import QEvent, Qt, pyqtSlot" is not supported yet. You need to write this on separate lines
woshichuanqilz commented 4 years ago

Hi, thank you for the report and all the details. This made it easy to help you :)

Please note the following:

  1. pyforest is currently only supposed to run in Jupyter Notebook/Lab. This is also the reason why you see the Display.Javascript error. This error might be suppressed via adding a flag that it is not running in Jupyter. eg via adding a new method "pyforest.deactivate_javascript()" If this method is called, a flag will be toggled that suppresses the js
  2. I saw that you imported "from pyforest import *" This is the old way. In version 1.0.0 we changed this to "import pyforest"
  3. Nice to see that you are using a custom imports script. Please note that you can only import one name per line. Eg "from PyQt5.QtCore import QEvent, Qt, pyqtSlot" is not supported yet. You need to write this on separate lines

Get the error like this I git clone the repo and run setup.py still get this error. How to fix it?

Traceback (most recent call last):
  File "D:/python_project/Make_Write_Easier/emoji_process/get_emoji.py", line 5, in <module>
    pyforest.deactivate_javascript()
AttributeError: module 'pyforest' has no attribute 'deactivate_javascript'
8080labs commented 4 years ago

Yes, sorry, for the confusion. The deactivate_javascript function was just an idea for how we could implement this in the future. It does not exist yet. If you want this, feel free to open a pull request to add this feature :)

8080labs commented 4 years ago

@woshichuanqilz are you interested in contributing a feature that suppresses the Javascript display?

woshichuanqilz commented 4 years ago

@woshichuanqilz are you interested in contributing a feature that suppresses the Javascript display?

sorry for the delay I am very gald to help ? how should I started since I never been a contributor before what should I learn first. I use python for several years. if I can help let me know thank you for your inviting

8080labs commented 4 years ago

The first step is to install pyforest locally on your computer from this repo and then have a look at the code. Once you thought through how to add the feature, you can write the new code. When you are done, you can create a pull request so that we can have a look at your code and the way that you wanted to implement this. At the beginning, this might seem a little bit intimidating but you can find a lot of good resources about the steps above on Google. I hope that helps to outline the next steps? If you have more detailed questions or are stuck somewhere, please let us know

Amusac commented 3 years ago

In my Jupyterlab with pyforest, output area has much blank space. this has a relation with this issue? Do you have any solution? When I uninstalled pyforest, this doesn't occur. (Sorry for my poor English.)

Henryhaohao commented 3 years ago

@woshichuanqilz Hello, you can comment out lines 105 to 113 in the _importable.py file, which is the "display" function in the "_update_import_cell" function definition.Then can not print .

666666

hgzech commented 3 years ago

In my Jupyterlab with pyforest, output area has much blank space. this has a relation with this issue? Do you have any solution? When I uninstalled pyforest, this doesn't occur. (Sorry for my poor English.)

@Amusac : Yes, this seems to be related to the blank line problem. @Henryhaohao's solution solves this problem, too.

gamis commented 3 years ago

This seems to fix it: https://github.com/8080labs/pyforest/pull/49 #49

tkrabel commented 5 months ago

The fix has been merged