I am trying to port some code from 2.7 to 3.6, and I am having problems with the installing package configparser for py-3.6 in anaconda.
When I execute the following command, I get an error:
$ conda install -c anaconda configparser
UnsatisfiableError: The following specifications were found to be in conflict:
- configparser -> python[version='>=2.7,<2.8.0a0']
- python=3.6
The dependencies also gives me the same information:
conda info configparser
configparser 3.5.0 py27h5117587_0
---------------------------------
dependencies:
python >=2.7,<2.8.0a0
However, question-14087598 says the package is available in py-3.6. How should I install this package in anaconda?
(One solution in the above link suggests to install through the python program itself, but I would like to install through anaconda.)
The package configparser is a backport of a Python 3.5 standard module to older versions of Python. Unfortunately, it appears that the Anaconda version of this package is not packaged for Python 3.
However, you are using Python 3.6, so you can simply use the configparser which comes preinstalled with Python instead of installing anything.
It's possible that the source code you are attempting to port contains a line like this (which will fail if the backport is not installed):
from backports import configparser
You can probably replace that line with the following:
import configparser
There are minor differences between the 3.5-compatible version installed in the backport and the version provided by 3.6, but the 3.6 version should be backwards compatible for most reasonable use cases. The main purpose of the from backports form is to enable developing 2.x-compatible code in a 3.x-only environment without accidentally using new features that don't exist in the backport.
Related
I am unable to get dateutil installed in my Python code.
from dateutil import tz
ImportError: No module named dateutil
I had date-util installed (Python version is 3.7.3)
> pip3 install python-dateutil
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Requirement already satisfied: python-dateutil in /usr/lib/python3/dist-packages (2.7.3)
I cannot uninstall them (to reinstall). I get the following error
> sudo pip3 uninstall python-dateutil
Not uninstalling python-dateutil at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'python-dateutil'. No files were found to uninstall.
Then, I used the following command to uninstall:
> sudo apt-get remove python3-dateutil #This worked
> pip3 install python-dateutil
This works, but asks me to install cycler, kiwisolver, pyparsing, which I install using pip3. But I still cant get the python code working - has the same error (ImportError: No module named dateutil)
Any suggestions on what's going on?
I found a solution - The python code is being called from a bash script. It worked fine until recently. Recently I installed some other packages that installed python 2.x. So, the python scripts were using Python 2.x rather than 3.x. I had symbolic links to python 3.x, but that didn't help.
Now, I am explicitly use python3 mycode.py to overcome this issue.
I highly recommend to use conda environment instead of pip. See, there are several modules which do not give expected behaviour in pip (like pytorch).
Get the package installed using:
conda install -c conda-forge python-dateutil
returning the question, to get the package running it requires fulfillment of it's dependencies. If you are using python 3.7.3 its obvious that it may lack in some of the features of modern python 3.11 as a result you get the obvious error. The python package python-dateutil must have been configured according to the modern python language version.
Iam using python 3.11.1 and the package gets installed very perfectly. You may install old version of package or upgrade your python language version or use Conda as mentioned before.
I recently installed Anaconda spyder 2020 version, resulting in Python 3.7.6 being installed.
I previously had ffn installed and working.
Now when I run code that tries to import ffn, it comes up with Module not found - No module named 'ffn'.
However, when I issue pip freeze at the console, I can see ffn == 0.3.3
Can anybody shed any light on why I have having problems importing ffn?
If you install anaconda it will automatically install its own version of python with a specific directory for site-packages so either you need to find and use your old python binary or install ffn again this time with the newly installed anaconda since just syncing the two site-packages directories won't work because minor releases of python (e.g 3.7 and 3.5 ) aren't necessarily compatible.
I would like to use the package pyflann on python 3.5 (Win-64)
I use the app spyder from Anaconda 3 to write and compile my scripts.
I have installed the package pyflann using command prompt and conda. It seems that the installation was successful since when I type
conda list
in the command prompt, the list displayed includes
flann 1.8.3 3 ccordoba12
However, I am unable to import flann or pyflann into python.
import flann or import pyflann
yields :
no module named (flann or pyflann).
I have tried a few other approaches from recommendations on this site without success and resulting in similar failures outlined in other questions on the site. I could really use a concise step-by-step approach to successfully using pyflann on python 3.5 through spyder. Any thoughts or suggestions on completing the process I started through conda would be much appreciated
The conda package flann contains the library for flann.
The conda package pyflann contains the python bindings for this library.
Try the following:
(nasa) [rovers#mars ~]# conda install -c conda-forge pyflann
(nasa) [rovers#mars ~]# python -c 'import pyflann; print pyflann.__path__'
['/conda/lib/python2.7/site-packages/pyflann']
I have the Anaconda distribution installed for Mac. I have Mac OSX 10.8 (Mountain lion). The problem I don't often use Anaconda is because the default Python which it uses is 2.7 while I work on 3.3 or atleast prefer to work on that.
I really like the Spyder IDE of Anaconda. Is there a way I can get the default environment on Anaconda changed to 3.3 instead of 2.7 so that Spyder and iPython all use 3.3 default?
I see the following help from Anaconda site:
$ conda create -n py3k python=3 anaconda
Here python=3 and anaconda are package specifications, and it is the job of the SAT solver inside conda to find a consistent set of packages which satisfies these requirements. As the root environment uses Python 2, we had to specify the major version explicitly.
After adding the binary directory of the newly created environment to the PATH environment variable, which may be done using
$ source activate py3k
My question is I have separately installed Python 3.3 and associated Scientific Python packages like Pandas, numpy, scipy, scikit-learn etc using Homebrew so that it doesn't conflict with my Mac OS default Python 2.7. So now if I run the above Conda commands in Mac Terminal will it interfere with other Python packages I have installed using Homebrew? or will it automatically install/upgrade the python and other packages in the Anaconda library without interfering with either the Homebrew installed Python or Mac OS default Python?
Please advise.
No, the Homebrew and Anaconda Pythons will stay completely independent of one another. Just make sure you don't have PYTHONPATH set, which causes this to not be true.
Also, you should know that Spyder is not available for Python 3 in Anaconda yet, because PySide has not yet been built for Python 3.
I had installed Anaconda with python 2.7, but even after adding python3:
conda create --name Py3 python=3
spyder continued to call python2.7
creating an environment with BOTH spyder and python=3 worked for me:
conda create --name SpyPy3 python=3 spyder
I have Python 2.7.3 installed alongside Python 3.2.3 on an Ubuntu system.
I've installed urllib3 using pip and can import it from the python shell. When I open the python3 shell, I get a can't find module error when trying to import urllib3. help('modules') from within the shell also doesn't list urllib3.
Any ideas on how to get python3 to recognize urllib3?
You need to install it for each version of Python you have - if pip installs it for Python 2.7, it won't be accessible from 3.2.
There doesn't seem to be a pip-3.2 script, but you can try easy_install3 urllib3.