Conda gives error when I run any command with it.
Traceback (most recent call last):
File "/usr/local/bin/conda", line 7, in <module>
from conda.cli.main import main
File "/usr/local/lib/python2.7/dist-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/usr/local/lib/python2.7/dist-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/usr/local/lib/python2.7/dist-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/usr/local/lib/python2.7/dist-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named ruamel.yaml.comments
The module ruamel.yaml.comments will normally be loaded from site-packages/ruamel/yaml/comments.py, and not from site-packages/ruamel_yaml/comments.py
Conda seems to have problems with properly supporting namespaces (ruamel.) which I can only attribute to not (yet) being fully pip compatible. That although "namespaces are a honking good idea", and package namespaces have been around for many years.
Assuming you can extend "conda" installations with pip you could try to do a normal install of ruamel.yaml with:
pip install ruamel_yaml==0.11.14
I would not normally recommend such an old version, but that is more likely to work in combination with the version conda uses itself internally.
The alternative would be to switch to using python and pip without conda, that way you can just use the latest version of software from PyPI.
Try pip install ruamel.yaml
It works for me.
Try conda install ruamel.yaml ... pip didnt work for me
Try sudo pip install ruamel_yaml
I went into this file:
/anaconda2/lib/python2.7/site-packages/dateparser/utils/__init__.py
edited this line:
import ruamel.yaml as yaml
to read
import ruamel_yaml as yaml
Changing the dot to an underscore worked for me.... I hope it works for you.
this worked for me:
pip install --upgrade ruamel.yaml --ignore-installed ruamel.yaml
from an answer in matsci.org
https://matsci.org/t/modulenotfounderror-no-module-named-ruamel/36183
The above answer didn't work for me. I had to do a fresh install of the core conda components as described in the conda docs here. Copy and pasted below:
Issue: My conda is broken and I want to fix it without blowing away the current installation
I am getting a conda error and want to reinstall Miniconda to fix it but when I try, it gives me the error that Miniconda (or Anaconda) is already installed and will not let me continue. I want to force the installation.
Resolution: Install Miniconda using the -f (force) option
Download and install the appropriate Miniconda for your computer operating system from the Miniconda download page using the force or -f option as shown:
bash Miniconda3-latest-MacOSX-x86_64.sh -f
NOTE: Substitute the appropriate filename and version for your
operating system.
NOTE: Be sure that you install to same install location as your
existing install so it overwrites the core conda files and does not
install a duplicate in a new folder.
Go to anaconda3\lib\site-packages\rpcq_base.py
and change line #22 :
from ruamel import yaml
to
from ruamel_yaml as yaml
This might not be a popular answer, but it finally helped me after many hours of troubleshooting:
Uninstall conda (I used this stack overflow solution) and also rm -rf miniconda3 in my home directory, fwiw.
Reinstalled conda using data camp's tutorial.
No other solutions worked for me after lots of head banging.
For python3 use
pip3 install ruamel_yaml
if pip3 not installed try at first
sudo apt install python3-pip
For me this was a conda/pip error. I'd tried to install (cwltool in my case) through pip.
It completed successfully, but then running any command gave me the error like above.
ImportError: No module named ruamel.yaml.
It turned out that the pip binary wasn't part of my conda env and was installing cwltool into a completely separate location.
To resolve the issue I completed the following:
conda activate <env I want to install cwltool into>
conda install -y pip
# Run 'rehash' now if you're using zsh to ensure you're using the right pip
pip install cwltool
cwltool -h
To add to what #user612161 has said, go to the directory of parent module (dateparser in this case) requiring ruamel.yaml:
cd anaconda2/lib/python2.7/site-packages/dateparser
and change all occurrences of ruamel.yaml into ruamel_yaml by the following command (Linux):
find . -name '*.py' | xargs sed -i 's/ruamel.yaml/ruamel_yaml/g'
The quick and easy is to ignore the previously installed version in an upgrade
pip install --ignore-installed ruamel_yaml==0.17.4
I was trying to link Bloomberg to Python
pip install --index-url=https://bcms.bloomberg.com/pip/simple blpapi
pip install xbbg
so far, so good.... then I tried to import a module from the package xbbg:
from xbbg import blp
and I was faced with an error, it couldn't find "ruamel.yaml" within the "param.py" within the xbbg module
When I dug into the folder C:/Anaconda3/Lib/site-packages I could see that there was a folder there called ruamel_yaml so I went back to the param.py file and edited ruamel.yaml to be ruamel_yaml as suggested in other posts.
"from xbbg import blp" now worked and I'm able to take data directly from Bloomberg into Python now. Problem solved.
I have a feeling that this issue is being caused by downloading different versions at different times as I've found the learning curve to get setup on Python difficult with many false starts. I was tearing my hair out a bit because I just got Python up and running linked to Bloomberg on my work pc but when I tried to link Bloomberg up to Python on my laptop it kept getting stuck with the "ruamel" issue. The version of Python on my laptop is much older than the version on my work pc. What makes me think that its a version issue is that I did not have to edit ruamel.yaml to be ruamel_yaml in order for me to link Python and BB.
These are just ideas, I'm too inexperienced at this stage to offer much more than to share what happened.
Related
I need to use the sksparse.chomod package however my pycharm does not let me install it as it can't seem to find it.
I found the sksparse package on github and downloaded it but I do not know how to add a package downloaded from the internet into a conda environment. So, my first question would be can you download a package from github and add it to your conda environment, and how do you do this?
As I did not know how to do the above I instead saved the package within my project and thought I could simply import sksparse.cholmod. However, the line in my code that says import sksparse.cholmod as sks has no errors with it, so I assumed that meant this was ok, but when I try to run my file I get this error:
import sksparse.cholmod as sks
ModuleNotFoundError: No module named 'sksparse.cholmod'
If I have downloaded the package into my project why can't it be found, yet there are no errors when importing?
The cholmod file is a pyx file which I've been told should not be a problem.
Please could anyone help, I am reasonably new to python and I am looking for a straight forward solution that won't be time consuming.
It was an issue with windows, I was able to fix this using the instructions on this link
https://github.com/EmJay276/scikit-sparse
We must follow these steps precisely:
(This was tested with a Anaconda 3 installation and Python 3.7)
Install these requirements in order:
'''
conda install -c conda-forge numpy - tested with v1.19.1
conda install -c anaconda scipy - tested with v1.5.0
conda install -c conda-forge cython - tested with v0.29.21
conda install -c conda-forge suitesparse - tested with v5.4.0
'''
Download Microsoft Build Tools for C++ from https://visualstudio.microsoft.com/de/visual-cpp-build-tools/ (tested with 2019, should work with 2015 or newer)
Install Visual Studio Build Tools
Choose Workloads
Check "C++ Buildtools"
Keep standard settings
Run ''' pip install git+https://github.com/EmJay276/scikit-sparse '''
Test ''' from sksparse.cholmod import cholesky '''
Use all the versions stated for numpy etc, however with scipy I installed the latest version and it worked fine.
I am following this video. At 22:22, an error was found in this code:
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x {IMAGE_PATH + '/train'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/train.record'}
!python {SCRIPTS_PATH + '/generate_tfrecord.py'} -x{IMAGE_PATH + '/test'} -l {ANNOTATION_PATH + '/label_map.pbtxt'} -o {ANNOTATION_PATH + '/test.record'}
Post exact error message:
Traceback (most recent call last):
File "D:\info\1 Master\2 semster\RealTimeObjectDetection-main\Tensorflow\scripts\generate_tfrecord.py", line 29, in <module>
from object_detection.utils import dataset_util, label_map_util
File "C:\Users\bachir\PycharmProjects\pythonProject\venv\lib\site-packages\object_detection\utils\label_map_util.py", line 29, in <module>
from object_detection.protos import string_int_label_map_pb2
File "C:\Users\bachir\PycharmProjects\pythonProject\venv\lib\site-packages\object_detection\protos\string_int_label_map_pb2.py", line 5, in <module>
from google.protobuf.internal import builder as _builder
ImportError: cannot import name 'builder' from 'google.protobuf.internal' (C:\Users\bachir\PycharmProjects\pythonProject\venv\lib\site-packages\google\protobuf\internal\__init__.py)
First I tried to download some missing packages but same problem, I would like to help
Follow these steps:
Install the latest protobuf version (in my case is 4.21.1)
pip install --upgrade protobuf
Copy builder.py from .../Lib/site-packages/google/protobuf/internal to another folder on your computer (let's say 'Documents')
Install a protobuf version that is compatible with your project (for me 3.19.4)
pip install protobuf==3.19.4
Copy builder.py from (let's say 'Documents') to Lib/site-packages/google/protobuf/internal
Run your code
You need to upgrade to the latest version of the protobuf package:
pip install --upgrade protobuf.
The reason is that the Python classes are simplified since Protobuf v3.20.0. Straight from the release notes it says:
Protobuf python generated codes are simplified. Descriptors and
message classes' definitions are now dynamic created in
internal/builder.py. Insertion Points for messages classes are
discarded.
This explains why the generated Python code now refers to a builder module, which it cannot find if you haven't updated to the latest version of the protobuf package. This is not explained in the release notes, but I verified myself that it works if you upgrade the protobuf package.
For some reason, the builder.py file is missing from the protobuf package created from TensorFlow. A workaround is to simply copy the latest copy of builder.py from the protobuf repository into your local drive
wget https://raw.githubusercontent.com/protocolbuffers/protobuf/main/python/google/protobuf/internal/builder.py -O [PROTOBUF_PATH]/lib/python3.8/site-packages/google/protobuf/internal/builder.py
Solution with two steps
pip uninstall protobuf
pip install protobuf==4.21
just like Victor answered. When working with tensforflow for somereason when installing protobuf builder.py is missing in the related package.
https://raw.githubusercontent.com/protocolbuffers/protobuf/main/python/google/protobuf/internal/builder.py
copied and pasted this code and made it into a .py then took that file and pasted it in {your env location}/site-packages/google/protobuf/internal/builder.py
and everything has worked.
what worked for me:
pip uninstall protobuf
conda install protobuf
(im using miniconda3)
Facing the same issue while following the Object Detection TensorFlow tutorial on the "Test Installation" tab.
As mentioned above, dunno why protobuff 3.19.6 does not brings builder.py, so you just have to upgrade to to a higher version (lets say 4.21.1) copy builder.py and then downgrading to a tensorFlow compatible protobuff (in my case 3.19.6) and paste it. In my case I was using conda so, builder.py file location was:
C:\Users\ {userX}\miniconda3\envs\ {envname}\Lib\site-packages\google\protobuf\internal
After that, the test run smoothly =).
Best!
I could solve the issue by not compiling my .proto files with the newest version of the protoc compiler but by using the old version v3.19.4 (see https://github.com/protocolbuffers/protobuf/releases).
Because descriptor_pb2.py is generated from protoc. So you need to keep the compatibility between your buiding system and running system.
In one word, make sure that your protoc's version is less than or equal to protobuf's version.
FYI, you can download the according protoc directly from "https://github.com/protocolbuffers/protobuf/releases"
Copy file builder.py from where your installing python or if your using ananconda may the builder.py in C:\Users\bachir\anaconda3\Lib\site-packages\google\protobuf\internal, copy it then paste to C:\Users\bachir\PycharmProjects\pythonProject\venv\lib\site-packages\google\protobuf\internal
I use Anaconda Prompt and Environment on Windows 11.
I solved the problem by making the same version of the two Protobuf installs one is the Anaconda Protobuf install, and the other one is that I installed from https://github.com/protocolbuffers/protobuf/releases
In order to make the same version, I reinstall Protobuf releases that are compatible with the Anaconda Protoc installation.
You can see what is your Protobuf with pip list
yeah, i use python 3.8.
i saw https://grpc.io/docs/languages/python/quickstart/
and run the example code but it was failed.
there are many causes, i know.
well, no silver bullet! :}
i solved it with upgrade protobuf
I am unable to import the sqlite3 module in Python, version 3.5.0. Here's what I get:
>>> import sqlite3
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.5/sqlite3/__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "/usr/local/lib/python3.5/sqlite3/dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: No module named '_sqlite3'
I know, I know, there are PLENTY of StackOverflow posts and support forums across the web where people complain about this problem, but none of the posted solutions have worked for me so far. Here's where I've been:
I also have Python 2.6.6 installed on this server, which is running CentOS 6.8 x86_64. I can open up the Python REPL and import sqlite3 just fine when using Python 2.6.6. I can also use sqlite3 from straight from bash and nothing seems awry.
This helpful question looked promising. I tried to re-configure and re-compile Python3.5 with the --enable-loadable-sqlite-extensions option, as user jammyWolf suggested. Nope, same error still occurs.
I've been using virtual environments like a good boy, but I have root access to this server. So, I was a bad boy and ran python3 as root without any virtualenvs activated. Still no luck. So I don't think it has anything to do with permissions.
I noticed that in the error message, it says No module named '_sqlite3'. This thread suggests that the underscore before the module name means that the module is an implementation detail, and isn't exposed in the API. ... I'm not sure what to make of this information, but there may be a hint somewhere in there.
Any ideas?
Falsetru is correct, I am going to go into a bit more detail for those not familiar (linux instructions). If you are getting this error, chances are you are using a version of python that was compiled without the correct headers. Here's a step by step guide to get it sorted. (Python 3.X.X instructions)
Install the required sqlite libraries
sudo apt-get install libsqlite3-dev
Uninstall python (I'm using python 3.6.5 as an example in this guide)
sudo apt-get remove python3.6
Download python from source
cd /tmp && wget https://www.python.org/ftp/python/3.6.5/Python-3.6.5.tgz
Unpack the archive
tar -xvf Python-3.6.5.tgz
Configure
cd Python-3.6.5 && ./configure
Make and install (and go make coffee while you're at it)
make && sudo make install
If you did everything correctly running "python3.6 -V" should give you your python version. Note you will have to rebuild any virtual environments you have as well.
One final caveat you may encounter.
zipimport.ZipImportError: can't decompress data; zlib not available
This happens if you don't have the following zlib library installed:
sudo apt-get install zlib1g-dev
Install sqlite-devel package which includes header, library that is required to build sqlite3 extension.
yum install sqlite-devel
NOTE: Python does not include sqlite3 library itself, but an extension module (wrapper).
I copied sqlite3.dll to this folder:
C:\Users\*****\Anaconda3\DLLs
It worked after two weeks trying everything else.
I need to install PIL (python imaging library) on my Ubunto10.4-32bit (EDIT:64bit) machine on my python2.5.4-32bit.
This question is also relevant to any other source package I guess (among those that I need are RPyC,psyco and numpy).
I downloaded the source-code since I can't find any neat package to do the job and did
a sudo python2.5 setup.py install.
output:
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Traceback (most recent call last):
File "setup.py", line 9, in <module>
import glob, os, re, struct, string, sys
File "/usr/lib/python2.5/struct.py", line 30, in <module>
from _struct import Struct, error
ImportError: No module named _struct
but
echo $PYTHONHOME
/usr
Well, in the file struct.py theres the line from _struct import Struct, error
This is part of the python source code itself so I really wonder whats wrong with the python installation, since the code fails to import the module.
I installed py2.5.4 by doing:
./configure --prefix=/usr
make altinstall
(using make altinstall since I need py26 as default python interpreter)
EDIT: This issue might have risen from mistakenly using a 64bit platform :) and 32bit python2.5 . So anyhow problem solved by reducing unnecessary complexities - switching to 32bit machine and porting app to python 2.6.
In short:
Try using the Ubuntu repository first. If the package isn't there, use easy_install. If all fails, download the package directly to your source folder.
Ubuntu repository (the apt-get approach)
Ubuntu (10.04 and newer) has most mainstream packages are available with apt-get. The naming convention is python-NAME, e.g. python-imaging or python-scipy.
This is the best way to go, since the native package manager will handle any dependencies and updates issues.
Run apt-cache search python | grep "^python-" | less to see a list of packages available for your system (I have over 1,200 in my 10.04 machine).
Setuptools
For packages that are not part of the Ubuntu repository, you can use the python easy-install tool. First, install the setup tool:
sudo apt-get install python-setuptools
And you can install any Python package, e.g. colorworld, using easy-install:
sudo easy_install colorworld
This gives you some degree of protection (e.g., handles dependencies) but updates are generally manual, and it's a real pain to reinstall all these packages in a new computer.
Manual download
You can always download the source code to some directory and add it to your PYTHONPATH. It's the best approach when you just need to evaluate a package or apply some quick-and-dirty solution.
sudo aptitude install python-imaging
This will install PIL library.
sudo aptitude install python-imaging
That will install PIL. But I'm not really sure how to help with your other packages. Maybe try searching for them in synaptic.
I'm trying to convert some date/times to UTC, which I thought would be dead simple in Python - batteries included, right? Well, it would be simple except that Python (2.6) doesn't include any tzinfo classes. No problem, a quick search turns up python-dateutil which should do exactly what I need.
The problem is that I need to install it on Windows. I was able to upack the .tar.gz2 distribution using 7-zip, but now I'm left with a collection of files and no guidance on how to proceed. When I try to run setup.py I get the error "No module named setuptools".
If dateutil is missing install it via:
pip install python-dateutil
Or on Ubuntu:
sudo apt-get install python-dateutil
Why didn't someone tell me I was being a total noob? All I had to do was copy the dateutil directory to someplace in my Python path, and it was good to go.
Looks like the setup.py uses easy_install (i.e. setuptools). Just install the setuptools package and you will be all set.
To install setuptools in Python 2.6, see the answer to this question.
Install from the "Unofficial Windows Binaries for Python Extension Packages"
http://www.lfd.uci.edu/~gohlke/pythonlibs/#python-dateutil
Pretty much has every package you would need.
It is a little tricky for people who is not used to command prompt. All you have
to do is open the directory where python is installed (C:\Python27 by default) and open the command prompt there (shift + right click and select open command window here) and then type :
python -m pip install python-dateutil
Hope that helps.
Using setup from distutils.core instead of setuptools in setup.py worked for me, too:
#from setuptools import setup
from distutils.core import setup
If you are offline and have untared the package, you can use command prompt.
Navigate to the untared folder and run:
python setup.py install
Just run command prompt as administrator and type this in.
easy_install python-dateutil
You could also change your PYTHONPATH:
$ python -c 'import dateutil'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named dateutil
$
$ PYTHONPATH="/usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg":"${PYTHONPATH}"
$ export PYTHONPATH
$ python -c 'import dateutil'
$
Where /usr/lib/python2.6/site-packages/python_dateutil-1.5-py2.6.egg is the place dateutil was installed in my box (centos using sudo yum install python-dateutil15)
First confirm that you have in C:/python##/Lib/Site-packages/ a folder dateutil, perhaps you download it, you should already have pip,matplotlib, six##,,confirm you have installed dateutil by--- go to the cmd, cd /python, you should have a folder /Scripts. cd to Scripts, then type --pip install python-dateutil --
----This applies to windows 7 Ultimate 32bit, Python 3.4------
I followed several suggestions in this list without success. Finally got it installed on Windows using this method: I extracted the zip file and placed the folders under my python27 folder. In a DOS window, I navigated to the installed root folder from extracting the zip file (python-dateutil-2.6.0), then issued this command:
.\python setup.py install
Whammo-bammo it all worked.