traitlets.traitlets.TraitError in Pycharm - python

I am a beginner in python. I am facing the following problem.
Whenever I start pycharm Community edition (version 5.0.3), the Python console fails to starts and shows the following error:
usr/bin/python2.7 /usr/lib/pycharm-community/helpers/pydev/pydevconsole.py 53192 49994
Traceback (most recent call last):
File "/usr/lib/pycharm-community/helpers/pydev/pydevconsole.py", line 488, in <module>
pydevconsole.StartServer(pydev_localhost.get_localhost(), int(port), int(client_port))
File "/usr/lib/pycharm-community/helpers/pydev/pydevconsole.py", line 330, in StartServer
interpreter = InterpreterInterface(host, client_port, threading.currentThread())
File "/usr/lib/pycharm-community/helpers/pydev/pydev_ipython_console.py", line 26, in __init__
self.interpreter = get_pydev_frontend(host, client_port)
File "/usr/lib/pycharm-community/helpers/pydev/pydev_ipython_console_011.py", line 472, in get_pydev_frontend
_PyDevFrontEndContainer._instance = _PyDevFrontEnd()
File "/usr/lib/pycharm-community/helpers/pydev/pydev_ipython_console_011.py", line 303, in __init__
self.ipython = PyDevTerminalInteractiveShell.instance()
File "/usr/lib/python2.7/dist-packages/IPython/config/configurable.py", line 354, in instance
inst = cls(*args, **kwargs)
File "/usr/lib/python2.7/dist-packages/IPython/terminal/interactiveshell.py", line 328, in __init__
**kwargs
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 483, in __init__
self.init_readline()
File "/usr/lib/python2.7/dist-packages/IPython/core/interactiveshell.py", line 1816, in init_readline
if self.readline_use:
File "/home/vivekruhela/.local/lib/python2.7/site-packages/traitlets/traitlets.py", line 529, in __get__
return self.get(obj, cls)
File "/home/vivekruhela/.local/lib/python2.7/site-packages/traitlets/traitlets.py", line 507, in get
% (self.name, obj))
traitlets.traitlets.TraitError: No default value found for None trait of <pydev_ipython_console_011.PyDevTerminalInteractiveShell object at 0x7f7b0e682cd0>
Process finished with exit code 1
Couldn't connect to console process.
How can I connect to the pycharm console? I have already installed IPython in my system.

I had the same issue.
I solved this by updating ipython.
My version was 3.1.0, upgrading it to 4.1.1 solved it.
in my case:
workon project
pip install -U ipython

I've found that this happened because I had installed ipython version 4.x, and then reverted to 3.2.0, without uninstalling the traitlets more advanced version first. This did the trick then:
pip uninstall ipython[all]
pip uninstall traitlets
pip install ipython==3.2.0

In my case, this was due to a conflicting installation of IPython through pip and apt. Removing the apt-installed version using sudo apt remove ipython fixed the problem.

I initially tried unsuccessfully by trying
pip install -U ipython
But then tried following and it worked:
pip uninstall ipython[all]
pip uninstall traitlets
pip install ipython
Thanks #mirandes

Related

Incompatible libpng versions when running matplotlib

I'm trying to use facebook research's Detectron. When I run it, it gives me the following error:
libpng warning: Application built with libpng-1.6.21 but running with 1.5.12
Traceback (most recent call last):
File "tools/infer_simple.py", line 147, in <module>
main(args)
File "tools/infer_simple.py", line 139, in main
kp_thresh=2
File "/home/sid/DETECTRON/detectron/lib/utils/vis.py", line 391, in vis_one_image
fig.savefig(os.path.join(output_dir, '{}'.format(output_name)), dpi=dpi)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/figure.py", line 1834, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backend_bases.py", line 2267, in print_figure
**kwargs)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 2595, in print_pdf
file.finalize()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 595, in finalize
self.writeImages()
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1430, in writeImages
ob.id, smaskObject)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1416, in _writeImg
self._writePng(data)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/backends/backend_pdf.py", line 1366, in _writePng
_png.write_png(data, buffer)
RuntimeError: Could not create write struct
I'm running Ubuntu 16.04. I don't know where the application is finding the libpng 1.5.12 version. I could not find it in my system. I installed libpng16-16. It still gives me the same error. I tried out other solutions suggested on the platform but they didn't work
I guess the problem is that you sudo pip installed matplotlib and that the libpng version that is shipped with the manylinux installation package of matplotlib is confused with the libpng version that was installed by apt. I recommend using matplotlib inside a virtual environment.
# create venv
virtualenv ~/matplotlib-venv
# activate venv
source ~/matplotlib-venv/bin/activate
# install matplotlib
pip install matplotlib
pip install <everything else you need>
# run your script
python ~/path/to/your/srcript.py

pip throws TypeError: parse() got an unexpected keyword argument 'transport_encoding' when trying to install new packages

I am using the latest version of Anaconda3. I just installed it and I am trying to download some packages. I am using the Anaconda Prompt. While trying to use pip to do anything (including upgrading existing packages) I get the following traceback.
Exception:
Traceback (most recent call last):
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in run
wb.build(autobuilding=True)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 487, in _prepare_file
req_to_install, finder)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\req\req_set.py", line 428, in _check_skip_installed
req_to_install, upgrade_allowed)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 811, in get_page
inst = cls(resp.content, resp.url, resp.headers)
File "C:\Users\csprock\Anaconda3\lib\site-packages\pip\index.py", line 731, in __init__
namespaceHTMLElements=False,
TypeError: parse() got an unexpected keyword argument 'transport_encoding'
Any ideas? (this problem only started after I installed tensorflow) Thanks.
I had the same problem and what worked for me was updating pip with conda:
conda install pip
It changed my pip from 9.0.1-py36hadba87b_3 to 9.0.1-py36h226ae91_4 and solved issue.
download https://github.com/html5lib/html5lib-python/tree/master/html5lib and overwrite all the files within html5lib folder in your tensorflow environment
"envs\tensorflow\Lib\site-packages\html5lib"
Then you should be able to run any "pip install" commands after that
I ran into the same problem while installing keras (after I installed tensorflow 1.3 using pip) on the latest version of Anaconda 3. I was able to fix the problem by installing keras using conda conda install -c conda-forge keras
I was getting this exact error installing SerpentAI. All I did to fix it was run activate serpent in conda prompt and then I ran the command again. Not sure if it's applicable to your situation, but they seem close enough that it might.
EDIT - if the above didn't work, comment out this line:
That worked perfectly for me.
(this took a helpful member of our community 8 hours to debug)
This worked for me:
python -m pip install --upgrade tensorflow
pip3 install -U html5lib=="0.9999999"
worked for me
here's the html5lib bug on github
from: https://stackoverflow.com/a/39087283
Here was the fix for me:
cd /usr/share/python-wheels/
Contents of dir:
-rwxrwxrwx 1 www-data www-data 493905 Jul 22 2015 html5lib-0.999-py2.py3-none-any.whl
-rw-r--r-- 1 root root 112620 Apr 3 2019 html5lib-0.999999999-py2.py3-none-any.whl
Run:
mv html5lib-0.999-py2.py3-none-any.whl html5lib-0.999-py2.py3-none-any.whl.bak
pip3 works fine after. Was loading the old 0.999 version.

Pip error when using "pip install ..."

Using OSX El Capitan. Just installed a bunch of pip module and was following a few online tutorials, must have broken something as now I get the following error whenever I try to use pip (although python seems to run fine).
$ pip install pandas
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2837, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 451, in _build_master
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 639, in resolve
pkg_resources.DistributionNotFound: pip==1.5.6
Any helping fixing would be much appreciated.
Thanks.
Reinstall using easy_install. Close the terminal and reopen. Pip should now work.
Try updating pip first by typing pip install -U pip and the try pip install pandas. I myself use Anaconda/Miniconda. Most of the packages are well handled and the dependencies are taken care of as well by the conda package manager.

pip install permission error

I just recently re-installed Python 2 and Python 3 via homebrew and everything looked ok. However I updated pip3 as well as pip after installing python and then, when trying to install virtualenv, I get the below errors:
~> pip install virtualenv Collecting virtualenv Downloading virtualenv-13.1.2-py2.py3-none-any.whl (1.7MB) 100% |
████████████████████████████████| 1.7MB 361kB/s Installing collected
packages: virtualenv Exception: Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/pip/basecommand.py", line 211, in main status = self.run(options, args)
File "/usr/local/lib/python3.4/site-packages/pip/commands/install.py", line 311, in run root=options.root_path, File "/usr/local/lib/python3.4/site-packages/pip/req/req_set.py", line 646, in install **kwargs
File "/usr/local/lib/python3.4/site-packages/pip/req/req_install.py", line 803, in install self.move_wheel_files(self.source_dir, root=root)
File "/usr/local/lib/python3.4/site-packages/pip/req/req_install.py", line 998, in move_wheel_files isolated=self.isolated, File "/usr/local/lib/python3.4/site-packages/pip/wheel.py", line 479, in move_wheel_files maker.make_multiple(['%s = %s' % kv for kv in console.items()]) File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 364, in make_multiple filenames.extend(self.make(specification, options))
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 353, in make self._make_script(entry, filenames, options=options)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 257, in _make_script self._write_script(scriptnames, shebang, script, filenames, ext) File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/scripts.py", line 231, in _write_script self._fileop.write_binary_file(outname, script_bytes)
File "/usr/local/lib/python3.4/site-packages/pip/_vendor/distlib/util.py", line 388, in write_binary_file with open(path, 'wb') as f:
PermissionError: [Errno 13] Permission denied: '/usr/local/bin/virtualenv'
pip freeze then seems to think virtualenv is installed but none of it's commands work.
Interestingly if I try to uninstall virtualenv it seems to have it attached to the Python 3 installed by brew installed of the Python 2 version brew installed.
Uninstalling virtualenv-13.1.2:
/usr/local/lib/python3.4/site-packages/__pycache__/virtualenv.cpython-34.pyc
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/DESCRIPTION.rst
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/METADATA
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/RECORD
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/WHEEL
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/entry_points.txt
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/metadata.json
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/pbr.json
/usr/local/lib/python3.4/site-packages/virtualenv-13.1.2.dist-info/top_level.txt
/usr/local/lib/python3.4/site-packages/virtualenv.py
/usr/local/lib/python3.4/site-packages/virtualenv_support/__init__.py
/usr/local/lib/python3.4/site-packages/virtualenv_support/__pycache__/__init__.cpython-34.pyc
/usr/local/lib/python3.4/site-packages/virtualenv_support/argparse-1.3.0-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/pip-7.1.2-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/setuptools-18.2-py2.py3-none-any.whl
/usr/local/lib/python3.4/site-packages/virtualenv_support/wheel-0.24.0-py2.py3-none-any.whl
Proceed (y/n)?
pip freeze gives me:
~> pip freeze
pbr==1.6.0
virtualenv==13.1.2
virtualenv-clone==0.2.6
wheel==0.24.0
so virtualenv already installed but doesn't work for some reason.
For python 2.7 I believe pip is referenced by pip2. Your permission error is easily fixed by running the command as sudo.

trouble with pip and easy_install to install python packages

I am going to install numpy library as a *.whl file, as numpy-1.9.2rc1+mkl- cp27-none-win32, on my Windows 7 machine...
Here is my approaches to do that, are which pip and easy_install packages...
The odd thing is that both don't work in the case of either Python 3.4 or Python 2.7...
Here are the trace of the attempts in the command prompt:
pip:
"C:\Users\Matinking\Desktop\numpy- 1.9.2rc1+
mkl-cp27-none-win32.whl" f
Exception:
Traceback (most recent call last):
File "c:\python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "c:\python34\lib\site-packages\pip\commands\install.py", line 257, in r
InstallRequirement.from_line(name, None))
File "c:\python34\lib\site-packages\pip\req.py", line 172, in from_line
return cls(req, comes_from, url=url, prereleases=prereleases)
File "c:\python34\lib\site-packages\pip\req.py", line 70, in __init__
req = pkg_resources.Requirement.parse(req)
File "c:\python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2667
in parse
reqs = list(parse_requirements(s))
File "c:\python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2605
in parse_requirements
line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),"version spec")
File "c:\python34\lib\site-packages\pip\_vendor\pkg_resources.py", line 2573
in scan_list
raise ValueError("Expected "+item_name+" in",line,"at",line[p:])
ValueError: ('Expected version spec in', ' C:\\Users\\Matinking\\Desktop\\numer
performance.pdf', 'at', ':\\Users\\Matinking\\Desktop\\numericperformance.pdf'
Storing debug log for failure in C:\Users\Matinking\pip\pip.log
and easy_install:
C:\Python34\Scripts>easy_install.exe "C:\Users\Matinking\Desktop\numpy- 1.9.2rc1+
mkl-cp27-none-win32.whl"
Processing numpy-1.9.2rc1+mkl-cp27-none-win32.whl
Writing C:\Users\MATINK~1\AppData\Local\Temp\easy_install- jr2ijafr\numpy\setup.c
fg
Running numpy\setup.py -q bdist_egg --dist-dir C:\Users\MATINK~1\AppData\Local\T
emp\easy_install-jr2ijafr\numpy\egg-dist-tmp-umy5kseg
This is the wrong setup.py file to run
No eggs found in C:\Users\MATINK~1\AppData\Local\Temp\easy_install-jr2ijafr\nump
y\egg-dist-tmp-umy5kseg (setup script problem?)
Any idea for the problem?!
You should upgrade your pip to version 6.0, the .whl file you're using isn't compatible with earlier versions.
To bump up your pip version on Windows :
python -m pip install -U pip
pip error -> why were you running an install on a pdf? That was never going to work.
easy_install error -> looks like you downloaded a python 2.7 binary and tried to install into a python 3.4 installation.
For scientific stack python, you are hard pressed to beat an Anaconda python distribution.

Categories