I have just tried to upgrade everything in my main environment to the latest version (using conda update --all). Everything went completely fine until I actually tried to run python. I got this error message:
Traceback (most recent call last):
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 579, in <module>
main()
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 562, in main
known_paths = venv(known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 494, in venv
addsitepackages(known_paths, [sys.prefix])
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "C:\Users\Ayush\Anaconda3\lib\site.py", line 159, in addpackage
f = open(fullname, "r")
File "C:\Users\Ayush\Anaconda3\lib\_bootlocale.py", line 12, in getpreferredencoding
if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'
As you can see, it looks like a problem with sys.flags. I tried googling this, but I couldn't find anyone with the same issue. I am using python 3.6.7 (python didn't update itself). This error message also appears if I try to run python in the command prompt. Here is the output of running conda update --all. Hope you can help!
EDIT: I found an issue on this issue on github here, but this doesn't give any explanations on how to fix this.
NOTE: I have also tried to install a new version of python using the installer, but that didn't work either.
I somehow did it - I re-installed Python, and then I tried using the command prompt, and it worked. It turned out that if I deleted my idea folder in Pycharm, it would work with the new version!
Related
I'm using the code found on this gist: https://gist.github.com/aldous-rey/68c6c43450517aa47474#file-transposer-py and when I run the script on MIDIs I have, including one from the author, I get the error
AttributeError: 'Rest' object has no attribute 'pitches'
It's quite old code, I had to modify a bit to fit python 3.9.1. I'm using the latest at this time music21 version 7. Was there any changes to the write() function that breaks this code?
EDIT: Here is the entire traceback:
Traceback (most recent call last):
File "C:\Users\username\path\to\transposer.py", line 28, in <module>
newscore.write('midi',newFileName)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 328, in write
return super().write(fmt=fmt, fp=fp, **keywords)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\base.py", line 2665, in write
return formatWriter.write(self,
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\converter\subConverters.py", line 1147, in write
mf = midiTranslate.music21ObjectToMidiFile(obj, **midiTranslateKeywords)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 260, in music21ObjectToMidiFile
return streamToMidiFile(music21Object, addStartDelay=addStartDelay)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 2559, in streamToMidiFile
midiTracks = streamHierarchyToMidiTracks(s,
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\midi\translate.py", line 2443, in streamHierarchyToMidiTracks
subs.stripTies(inPlace=True, matchByPitch=False)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 7283, in stripTies
endMatch = updateEndMatch(n)
File "C:\Users\username\AppData\Local\Programs\Python\Python39\lib\site-packages\music21\stream\base.py", line 7166, in updateEndMatch
and nLast is not None and len(nLast.pitches) == len(nInner.pitches)):
AttributeError: 'Rest' object has no attribute 'pitches'
Yes, this is a bug in version 7, but thanks to this report, I've opened a pull request to fix the issue.
There might be a bug-fix release this fall, or you could also just pull from the development version once the PR is merged, e.g. pip uninstall music21 and pip install git+https://github.com/cuthbertLab/music21.git. Thanks again for reporting!
I also faced the same problem. In my case I downgraded the version of music21 to version 6.7.1 and it started working like a charm. :)
pip install --upgrade music21==6.7.1
I was running python 2.7 in Anaconda2 in spyder 4 up until today with no problems. But now I keep getting the same error, when I make an environment and install python 2.7 and spyder in it:
Traceback (most recent call last):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3718, in main
mainwindow = run_spyder(app, options, args)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 3557, in run_spyder
main = MainWindow(options)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/app/mainwindow.py", line 426, in init
from spyder.preferences.runconfig import RunConfigPage
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences /runconfig.py", line 482, in
class RunConfigPage(GeneralConfigPage):
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/preferences/runconfig.py", line 487, in RunConfigPage
ICON = ima.icon('run')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/spyder/utils/icon_manager.py", line 394, in icon
directory=_resource['directory'])
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 178, in load_font
return _instance().load_font(prefix, ttf_filename, charmap_filename, directory)
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/init.py", line 54, in _instance
'materialdesignicons-webfont-charmap.json')
File "/home/cmiprc/anaconda2/envs/test/lib/python2.7/site-packages/qtawesome/iconic_font.py", line 206, in init
super().init()
TypeError: super() takes at least 1 argument (0 given)
This started happening after I reinstalled the package "pydicom" in the environment, and now nothing works. I have reinstalled anaconda2, used spyder --reset, and all other common suggestions.
Spyder 3.3.6 works in the base environment, but every time I make a new environment and install spyder in this, I get the same error. Any suggestions?
(Spyder maintainer here) To fix this problem, you need to install QtAwesome 0.7.3 in your environment. For that, please use the following command:
conda install qtawesome=0.7.3
I created a conda environment with user1 and now trying to use it with user2 on a Ubuntu machine. I run:
conda activate /path/to/env
Activation seems to work OK, but when I try to run python I get:
$ python
Failed to import the site module
Traceback (most recent call last):
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/site.py", line 586, in <module>
main()
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/site.py", line 573, in main
known_paths = addsitepackages(known_paths)
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/site.py", line 349, in addsitepackages
addsitedir(sitedir, known_paths)
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/site.py", line 207, in addsitedir
addpackage(sitedir, name, known_paths)
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/site.py", line 159, in addpackage
f = open(fullname, "r")
File "/powerapps/share/miniconda3-4.7.12/lib/python3.7/_bootlocale.py", line 35, in getpreferredencoding
if sys.flags.utf8_mode:
AttributeError: 'sys.flags' object has no attribute 'utf8_mode'
With user1 (that created the env), everything works fine.
Also, if I do conda deactivate with user2, python runs fine.
When I run which python, with both users I get /path/to/env/bin/python.
The env recipe contains the dependency "python=3" (along with others), and the version that was actually installed is 3.6.10.
I understand that this has to do with some python2/3 incompatibility, but I don't understand why this is happenning. Any idea what's going on and how to fix it?
Thanks!
If found some hits on stackoverflow where people have issues using ete3 tools when PyQT4 is not installed, and this (used to) also apply for me. However, I've now tried to reinstall a piece of software and it keeps complaining about 'Module' has no attritube 'Treestyle'.
To test whether PyQT was installed, I ran this python script:
from PyQt4.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
Which prints:
('PyQt version:', '4.12.1')
I get this (common) error:
Traceback (most recent call last):
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1820, in <module>
sys.exit(main())
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 1793, in main
args.start(args)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 408, in start_evo_sim
result = init_and_simulate(simu, intermediate_load_file, _options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 117, in wrapper
raise ex_type(message)
AttributeError: 'module' object has no attribute 'TreeStyle' (in subprocess)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/my_tools/utility.py", line 91, in process_func
ret = func(*args, **kwargs)
File "/mnt/f/mypy/bin/virtualmicrobes.py", line 295, in init_and_simulate
sim = sim_mod.create_simulation(**options)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1940, in create_simulation
sim = ODE_simulation(params_dict)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 1342, in __init__
super(ODE_simulation, self).__init__(params)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 86, in __init__
self.init_graphs()
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/simulation/Simulation.py", line 795, in init_graphs
show=show, clean=clean, create=create)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1188, in __init__
self.init_phylo_tree_graph(clean=clean)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1219, in init_phylo_tree_graph
show=show, attribute_dict=self.attribute_mapper, create=clean, **kwargs)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 985, in __init__
self.init_tree_style_dict() # NOTE: unordered ok
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1110, in init_tree_style_dict
branch_vertical_margin=branch_vertical_margin)
File "/mnt/f/mypy/local/lib/python2.7/site-packages/VirtualMicrobes/plotting/Graphs.py", line 1083, in make_tree_style
ts = ete3.TreeStyle()
Note: this time arround I am trying to install it on Ubuntu for Windows, but up till now almost everything that ran on Linux ran on this one too. It might be relevent though.
Any ideas?
PS To reproduce the problem, follow the following steps:
$ sudo apt-get install python-qt4
$ virtualenv ~/mypy --system-site-packages
$ source ~/mypy/bin/activate
$ (mypy) > pip install VirtualMicrobes
$ (mypy) > virtualmicrobes evo --name TestMicrobes >> error
PPS User eyllanesc confirmed this is an 'Ubuntu for Windows' problem. I'm still trying to fix it though, if anyone can help me figure out how to link the pyqt4 packages correctly to my virtualenv that would be great. I've tried linken the native one with ln -s but I'm not getting any further
I had similar issues. The problem might be that you don't have all the depencies installed and ete3 is not telling you all of them.
You can see which dependencies are missing with this code:
import ete3
ete3.__file__
Run it and it will tell you which dependencies are missing. Note that you might need to run it multiple times before you install them all!
I am trying to use the Tensonflow debugger in PyCharm. When I do I get this error: _curses.error: setupterm: could not find terminal
Here is the full traceback:
Traceback (most recent call last):
File "/Users/mddrill/PycharmProjects/NumberReaderNN/number_reader.py", line 163, in <module>
[optimizer, loss_func, train_prediction], feed_dict=feed_dict
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/wrappers/framework.py", line 411, in run
self._run_call_count))
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py", line 210, in on_run_start
self._prep_cli_for_run_start()
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/wrappers/local_cli_wrapper.py", line 228, in _prep_cli_for_run_start
self._run_cli = ui_factory.get_ui(self._ui_type)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/cli/ui_factory.py", line 56, in get_ui
return curses_ui.CursesUI(on_ui_exit=on_ui_exit)
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/cli/curses_ui.py", line 263, in __init__
self._screen_init()
File "/anaconda/lib/python3.6/site-packages/tensorflow/python/debug/cli/curses_ui.py", line 374, in _screen_init
self._stdscr = curses.initscr()
File "/anaconda/lib/python3.6/curses/__init__.py", line 30, in initscr
fd=_sys.__stdout__.fileno())
_curses.error: setupterm: could not find terminal
The debugger works if I run the code from a terminal, so this is definitely a PyCharm issue.
I have tried what I saw in another answer which is to add TERMINFO=/etc/terminfo to the environment variables in Run>Edit Configurations>Defaults>Python and that didn't work. The answer pertained to linux, and I'm on Mac OS X.
How can I get the Tensonflow debugger to work in PyCharm on Mac OS X?
UPDATE: You are right, it seems this is an open issue in PyCharm:
https://youtrack.jetbrains.com/issue/PY-13062
OLD: Tipically, you need to set the proper environment variables:
export TERM=xterm-new
export TERMINFO=/etc/terminfo
An almost identical problem has been discussed here: Setupterm could not find terminal, in Python program using curses
You could go the 'Edit Configuration' page, and select 'Emulate in output console'.