pycharm: show only program output in console? - intellij-idea

In older versions of pycharm, the only things that appeared in the output window was the ones that I explicitly printed.
I recently updated it, and now it also prints everything that happens under the hood when the program runs (reading environment variables, setting path, running script, etc), so it's difficult to make out the actual output.
eg, a simple print('hello world') gives
import sys; print('Python %s on %s' % (sys.version, sys.platform))
import django; print('Django %s' % django.get_version())
sys.path.extend(['/Users/...', '/Users/...', '/Applications/PyCharm.app/Contents/helpers/pycharm', '/Applications/PyCharm.app/Contents/helpers/pydev'])
if 'setup' in dir(django): django.setup()
import django_manage_shell;
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
Type 'copyright', 'credits' or 'license' for more information
IPython 6.2.1 -- An enhanced Interactive Python. Type '?' for help.
PyDev console: using IPython 6.2.1
Python 3.6.4 (v3.6.4:d48ecebad5, Dec 18 2017, 21:07:28)
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Django 2.2.6
/Users/.../venv/lib/python3.6/site-packages/psycopg2/__init__.py:144: UserWarning: The psycopg2 wheel package will be renamed from release 2.8; in order to keep installing from binary please use "pip install psycopg2-binary" instead. For details see: <http://initd.org/psycopg/docs/install.html#binary-install-from-pypi>.
""")
Backend MacOSX is interactive backend. Turning interactive mode on.
runfile('/.../snippet.py', wdir='/Users/...')
hello world
How can I bring back the previous behavior?

Related

Pandas runtime error /anaconda3/lib/python3.8/site-packages/pandas/__init__.py", line 13 missing_dependencies

I need to do some stuff using pandas.
Inside my python file, I wrote this:
sys.path.append("/home/user0/anaconda3/lib/python3.8/site-packages")
import pandas as pd
When I run the program,I get this:
File "/home/user0/anaconda3/lib/python3.8/site-packages/pandas/__init__.py", line 13
missing_dependencies.append(f"{dependency}: {e}")
^
SyntaxError: invalid syntax
I installed Anaconda, and I can verify that pandas is available.
My working environment is inside Anaconda's virtual environment, where python version is 3.8.
When I "conda deactivate", my python version is 2.7.
When I login to the server, my Anaconda env is already activated, and I get a prompt like this:
(base) user0#optiplex:~$
"conda list" tells me my pandas version is 1.0.5, and numpy is 1.18.5.
I have already updated Anaconda using "conda update --all". No improvement.
Some diagnostics:
(base) user0#optiplex:~$ python
Python 3.8.3 (default, Jul 2 2020, 16:21:59)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/home/user0/anaconda3/bin/python'
>>> import sys
>>> sys.path
['', '/home/user0/anaconda3/lib/python38.zip', '/home/user0/anaconda3/lib/python3.8',
'/home/user0/anaconda3/lib/python3.8/lib-dynload',
'/home/user0/anaconda3/lib/python3.8/site-packages']
>>>
Someone please give me some hints.
Thank you.
First, I tried different keywords and googled, and landed on exactly this item in stack overflow!
It mentions may be there is python version mismatch.
https://ja.stackoverflow.com/questions/67370/import-pandas-%E3%81%A7-pandas-init-py-%E3%81%AB%E5%AF%BE%E3%81%97%E3%81%A6-syntaxerror-%E3%81%8C%E3%81%A7%E3%81%BE%E3%81%99
I was running my code inside another program that uses python 2.x internally, so it could be the case, I don't know. I don't know much about python, specially working env setup, so I cannot make anymore comments.
Second, I ran the code once again, right after the first error, and the second time, the program worked. I don't know what to make of it either.
BTW, AtanuCSE, thank you for formatting my question!

Error in Power BI while importing pandas library in python scrip

Below are the mentioned error while importing pandas library in Power BI in python script.
Details: "ADO.NET: Python script error.
C:\USERS\YADAVP\ANACONDA3\lib\site-packages\numpy\__init__.py:140: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
from . import _distributor_init
Traceback (most recent call last):
File "PythonScriptWrapper.PY", line 2, in <module>
import os, pandas, matplotlib
File "C:\USERS\YADAVP\ANACONDA3\lib\site-packages\pandas\__init__.py", line 17, in <module>
"Unable to import required dependencies:\n" + "\n".join(missing_dependencies)
ImportError: Unable to import required dependencies:
numpy:
IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!
Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
1. Check that you expected to use Python3.7 from "C:\USERS\YADAVP\ANACONDA3\python.exe",
and that you have no directories in your PATH or PYTHONPATH that can
interfere with the Python and numpy version "1.18.1" you're trying to use.
2. If (1) looks fine, you can open a new issue at
https://github.com/numpy/numpy/issues. Please include details on:
- how you installed Python
- how you installed numpy
- your operating system
- whether or not you have multiple versions of Python installed
- if you built from source, your compiler versions and ideally a build log
- If you're working with a numpy git repository, try `git clean -xdf`
(removes all files not under version control) and rebuild numpy.
Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.
Original error was: DLL load failed: The specified module could not be found.
What is the resolution to sort this kind of error in Power BI?
Forget Anaconda and use WinPython.
I tried Anaconda for days with all the workarounds available in StackOverflow and other forums, and they took me nowhere.
Then I tried WinPython, and it worked immediately. Of course, you will need to change the PowerBI options accordingly.
To install WinPython: https://github.com/winpython/winpython
To change the detected Python home directory: https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts#enable-python-scripting
If you consider my answer, you won't need to downgrade Python, PBI, or anything else.
I had the same error. Unfortunately, PowerBI wont work with Jupyter Notebook Python.
So you have to install a "normal" Python: https://www.python.org/downloads/
And configure the Python you want to use in PowerBI and install your needed Python libraries via pip
Edit: Please use Python 3.8 because 3.9 doesnt support NumPy for now

Python 3.7 + Visual Studio 2107 + boost 1.69

I am trying to get boost 1.69 working with visual studio 2107. My goal is to use Numpy in C++
When I include #include boost/python/numpy.hpp
The error I am getting is:
Searching C:\boost_1_69_0\stage\lib\boost_python37-vc141-mt-gd-x32-1_69.lib:
1>LINK : fatal error LNK1104: cannot open file 'boost_numpy37-vc141-mt-gd-x32-1_69.lib'
I am pretty sure that I have this file in this directory.
My architucture in the project is x86, 32-bit addrressing
I built boost as follows:
.\bbotstarp.bat
.\b2 -j8 --toolset=msvc-14.1 --build-type=complete link=static runtime-link=static architecture=x86 address-model=32 stage --with-python
I added the include and link folders to the project.
I do not use precompiled headers
Is there anything that I am missing?
Thanks
I had the same problem. It seems like Boost python is not supported by python 3.7 vert well.
Using python 3.6 will solve this problem.
I have been looking at this issue for months and finally figure out the root cause and solutions. The root cause that boost numpy is not built is because numpy is unable to be imported when ./b2 checks for numpy. As a clue from this post Using boost numpy with visual studio 2019 and python 3.8, you can append --debug-configuration to see the debugging information of boost python building process like this in my PC
notice: [python-cfg] Checking for NumPy...
notice: [python-cfg] running command 'C:/Anaconda3_Install_Root/envs/my_envs/python -c "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())"'
And, the error comes from ImportError for some reason:
ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.
After looking at this post numpy is already installed with Anaconda but I get an ImportError (DLL load failed: The specified module could not be found), I found this import process has to be under python environment such as under conda environment or PyCharm terminal (They both work in my PC) with all the required PATH to be imported. Now I can generate numpy static library with Python 3.8, VS 2019, boost v1.74, Windows 10. The command I use to build boost python is .\b2 --with-python python-debugging=off threading=multi variant=release li
nk=static address-model=64 stage --debug-configuration. Hopefully, that will work in yours.

google-cloud-speech speech.types.RecognitionConfig

I am current running on Debian 8 Jessie with Python 2.7 and the current google-cloud-speech and storage (pip'd in with upgrade today). When I attempt to config it fails with:
ValueError: Protocol message RecognitionConfig has no "enable_automatic_punctuation" field.
from this call:
config = speech.types.RecognitionConfig(
encoding=speech.enums.RecognitionConfig.AudioEncoding.LINEAR16,
sample_rate_hertz=8000,
language_code='en-US',
# Enable automatic punctuation
enable_automatic_punctuation=True)
The call was directly copy/paste'd from "https://cloud.google.com/speech-to-text/docs/automatic-punctuation#speech-enhanced-model-python".
Huh?
enable_automatic_punctuation is only available if you import speech_v1p1beta1 instead of speech_v1. Compare the documentation for RecognitionConfig for both beta and non beta.
Also, in the very same example that you have linked, if you click on View on Github, you can see the following import:
from google.cloud import speech_v1p1beta1 as speech
Also, related to this topic.
EDIT:
Also, that code is on Python 3, and you are using Python 2.7, be aware of that.

Gtk warning after ugrading to yosemite

I am trying to run a program written in python on my mac (Yosemite).
Almost immediately after starting the program it gives me the following error:
Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
[edit] tried to isolate the issue, the error appears upon entering
Adriaan$ ipython --gui=gtk
Python 2.7.8 (default, Nov 5 2014, 15:41:54)
Type "copyright", "credits" or "license" for more information.
IPython 2.3.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
(process:969): Gtk-WARNING **: Locale not supported by C library.
Using the fallback 'C' locale.
I have tried reinstalling X11(v2.7.7) and rebooting. (as listed in similar threads).
Does anyone know how to resolve this error?
Try to run Xquartz.app first. Then:
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot
Generally works for me after each OS upgrade.