I'm trying to get started using music21 in python. I've imported the package into PyCharm but when I use the line:
import music21
at the start of my file, it gives me:
Traceback (most recent call last):
File "C:/Users/Miles/Documents/Miles/Uni/Coding/Music21/Start.py", line 1, in <module>
import music21
File "C:\Users\Miles\Documents\Miles\Uni\Coding\Music21\venv\Environment\lib\site-packages\music21\__init__.py", line 169, in <module>
from music21 import base # noqa: E402
File "C:\Users\Miles\Documents\Miles\Uni\Coding\Music21\venv\Environment\lib\site-packages\music21\base.py", line 119, in <module>
loader = importlib.util.find_spec(modName)
AttributeError: module 'importlib' has no attribute 'util'
It works fine when I try to run it from the python console, and I'm using python 3.7 and music21 version 6.5 which should be compatible so not sure where I'm going wrong.
Fixed in the unreleased version (current development branch on GitHub).
See this issue and linked PR:
https://github.com/cuthbertLab/music21/issues/750
Since you are saying it works for you in python console, I suggest installing music21 package in PyCharm. Refer the following document for installing packages in PyCharm.
https://www.jetbrains.com/help/pycharm/installing-uninstalling-and-upgrading-packages.html
Related
So I have python version 3.8.12, and while trying to build a cloudrun app, I get the error:
ERROR: gcloud failed to load: module 'collections' has no attribute 'Mapping'
Now when I try to run and install Gcloud SDK again, I get the error:
Welcome to the Google Cloud SDK! Traceback (most recent call last): File "/Users/eshanchatty/downloads/./google-cloud-sdk/bin/bootstrapping/install.py", line 12, in <module>
import bootstrapping File "/Users/eshanchatty/Downloads/google-cloud-sdk/bin/bootstrapping/bootstrapping.py", line 46, in <module>
from googlecloudsdk.core.updater import update_manager File "/Users/eshanchatty/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/updater/update_manager.py", line 39, in <module>
from googlecloudsdk.core.console import progress_tracker File "/Users/eshanchatty/Downloads/google-cloud-sdk/lib/googlecloudsdk/core/console/progress_tracker.py", line 651, in <module>
class _BaseStagedProgressTracker(collections.Mapping): AttributeError: module 'collections' has no attribute 'Mapping'
What is causing this, and how can I solve this?
Yesterday I updated Fedora to version 35. This version uses Python 3.10 by default.
In this version, collections does not have Mapping. I got the same errors as you did.
I haven't tried to reinstall Google Cloud SDK. Instead, I wrote this line to my ~/.bashrc file:
export CLOUDSDK_PYTHON=python2
Then closed and opened the terminal.
Now the SDK uses Python 2 instead of Python 3. This solved the issue for me.
I used this doc to fix my python on macos, eventually after fixing python the issue got resolved.
https://gist.github.com/MuhsinFatih/ee0154199803babb449b5bb98d3475f7
I have a python script that uses the lib awswrangler. Today my scrpit started to give errors in the import of the library and I don't know what is happening.
I'm running the script in a docker container with image python: 3.8
Example:
import awswrangler as wr
print(wr.__version__)
Error:
Traceback (most recent call last):
File "src/avec/automation/TaskBaseUserPass.py", line 1, in <module>
from awswrangler.pandas import Pandas
File "/usr/local/lib/python3.8/site-packages/awswrangler/__init__.py", line 17, in <module>
from awswrangler.pandas import Pandas # noqa
File "/usr/local/lib/python3.8/site-packages/awswrangler/pandas.py", line 45, in <module>
class Pandas:
File "/usr/local/lib/python3.8/site-packages/awswrangler/pandas.py", line 273, in Pandas
def _read_csv_once_remote(send_pipe: mp.connection.Connection, session_primitives: "SessionPrimitives",
AttributeError: module 'multiprocessing' has no attribute 'connection'
I have been experienced the same issue today when trying to import awswrangler. For me, downgrading the following dependencies helped:
pip install fsspec==0.6.3 PyAthena==1.10.2 s3fs==0.4.0
It seems that one or more of them were causing the problem.
If your code uses multiprocessing.connection.Listener or multiprocessing.connection.Client, then you should use:
import multiprocessing.connection
If you just use
import multiprocessing
.. then your code might get an ImportError or not. It depends on other modules. If an other module imports multiprocessing.connection, then it will work.
But I guess you don't want random behavior, and that's why you should import multiprocessing.connection.
I managed to run version 3.6, the library has a problem with mp.connection.Connection in current python versions
I installed ros1 and created a catkin workspace. Inside the src folder I cloned a ros package "executive_smach_visualization". But when I try to run it with the following command I am getting an error.
rosrun smach_viewer smach_viewer.py
Traceback:
wxversion 2.8 is not installed, installed versions are ['3.0-gtk3']
Traceback (most recent call last):
File "/home/developer/catkin_ws/src/executive_smach_visualization/smach_viewer/scripts/smach_viewer.py", line 77, in <module>
from smach_viewer import xdot
File "/home/developer/catkin_ws/src/executive_smach_visualization/smach_viewer/src/smach_viewer/xdot/__init__.py", line 1, in <module>
import wxxdot
File "/home/developer/catkin_ws/src/executive_smach_visualization/smach_viewer/src/smach_viewer/xdot/wxxdot.py", line 22, in <module>
from xdot import *
File "/home/developer/catkin_ws/src/executive_smach_visualization/smach_viewer/src/smach_viewer/xdot/xdot.py", line 34, in <module>
import gobject
ImportError: No module named gobject
I have already tried following:
1) Installed goobject using pip
2) cloned gobject from git to src folder of catkin_ws, catkin_make and setup.bash
What could be the problem? Please let me know if I am missing any important input. Thanks in advance.
This issue occurs if there is different version of ros, python and so on.
It seems package is a little bit outdated.
Edit:
After downloading package and when building your working environment, use:
catkin_make -DPYTHON_EXECUTABLE=/usr/bin/python2 -DPYTHON_INCLUDE_DIR=/usr/include/python2.7 -DPYTHON_LIBRARY=/usr/lib/libpython2.7.so
Please refer to 1.5 section (User configuration) of this guide
Guys I'm facing a problem on using this module which i install from pip currently my OS is Windows python36 64bit version is install. When i'm using and try to import this module
from drawtree import draw_level_order
draw_level_order('{3,9,20,#,#,15,7}')
Why python giving strange errors like this
Traceback (most recent call last):
File "C:/Users/Root/PycharmProjects/untitled/src/Test.py", line 1, in <module>
from drawtree import draw_level_order
File "C:\Python36-64\lib\site-packages\drawtree\__init__.py", line 7, in <module>
from drawtree import draw_bst, draw_random_bst, draw_level_order
ImportError: cannot import name 'draw_bst'
The version of drawtree on PyPI is not currently compatible with Python 3. There's a Python 3-compatible version on Github, if you really want to use drawtree on Python 3.
My anaconda-based pandas install was working fine and then I got this error:
Traceback (most recent call last):
File "/xx/xx/test.py", line 3, in <module>
import pandas
File "/home/sc9/anaconda/lib/python2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
File "tslib.pyx", line 39, in init pandas.tslib (pandas/tslib.c:63127)
File "/home/sc9/anaconda/lib/python2.7/site-packages/pytz/__init__.py", line 29, in <module>
from pkg_resources import resource_stream
File "/home/sc9/anaconda/lib/python2.7/site-packages/setuptools-12.3-py2.7.egg/pkg_resources/__init__.py", line 1366, in <module>
File "/home/sc9/anaconda/lib/python2.7/site-packages/setuptools-12.3-py2.7.egg/pkg_resources/__init__.py", line 1370, in MarkerEvaluation
AttributeError: 'module' object has no attribute 'python_version'
running python test.py on this simple file is enough to reproduce:
#!/usr/bin/env python
import pandas
I think this line (1370) 'python_full_version': platform.python_version might be the problem as platform.py does not have a python_version attribute only the python_version() function. However I have never changed this and I don't see why it has stopped working when all was fine.
This error has also followed me from one ubuntu machine to another so I guess it must be something I'm doing in code rather than a corrupted library.
Strangely an IPython (2.2.0) console can run import pandas as pd fine but a regular python console will fail with the same error as above. I can debug my code from Pycharm but can't run, which is bemusing to me.
Any help appreciated.
I am developing principally in Pycharm using using python 2.7.9 (Anaconda 2.1.0), Pandas 0.14.1 on Ubuntu 14.0.4
Update: I tried running the simple import from a different directory using a regular python console and it worked. I found an import statement which looks like it might be causing the problem with the project I was working on: from twisted.python.runtime import platform this is used to do a platform check. I thought removing this would fix the problem but it seems to be persisting somewhere because it does not fix the problem.