I have been listing the packages in an environment using 'conda list'. The list that is then produced doesn't include packages that I know are installed in the environment, in this case, flickrapi.
((getpics)) C:\Users\Rdebbout>conda list fl
packages in environment at C:\Users\Rdebbout\AppData\Local\Continuum\Anaconda2\envs\getpics:
pyflakes 1.1.0 py27_0
This is pointing to the correct environment and if you look below, when I am in the same environment, I can import flickrapi without a problem
((getpics)) C:\Users\Rdebbout>ipython
Python 2.7.11 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:58:36) [MSCv.1500 64 bit (AMD64)]
Type "copyright", "credits" or "license" for more information.
IPython 4.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: from flickrapi import FlickrAPI
In [2]:
What is the reason for this?
Related
My version of Python is [MSC v.1916 32 bit (Intel)] on win32 but I cannot see a release 1916 in -
http://www.gisinternals.com/release.php
https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
https://trac.osgeo.org/osgeo4w/
Possibly I am misreading the websites. To be honest I found https://trac.osgeo.org/osgeo4w/ very confusing to navigate.
Can anyone give me any guidance?
Update
I used the 64bit OSGeo4W network installer from https://trac.osgeo.org/osgeo4w/
and everything is working now.
To find out if you need the 32 or 64 bit installer you can do
(project2_env) C:\Users\HP\django_project3>python
And it will give you below information.
Python 3.7.3 (default, Apr 24 2019, 15:29:51) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32
Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated. Libraries may fail to load. To activate this environment
please see https://conda.io/activation
Type "help", "copyright", "credits" or "license" for more information.
>>>
I have both Python 2.7 and 3.5 installed. If I run a script from the command line using python, it uses Python 2.7, but if I launch iPython, it uses Python 3:
kurt#kurt-ThinkPad:~$ python -V
Python 2.7.12
kurt#kurt-ThinkPad:~$ ipython
Python 3.5.2 (default, Sep 10 2016, 08:21:44)
Type "copyright", "credits" or "license" for more information.
IPython 5.1.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]:
Is there a way to launch iPython so that it uses Python 2? (I'm using Ubuntu LTS 16.04).
Less intrusive solution(as my solution below does not need changing any library files) to this problem is
python2.7 -m IPython notebook
so the general command is
{{python-you-want-ipython-to-use}} -m IPython notebook
Why will this work ?
Because if you see the ipython script (/usr/local/bin/ipython) it seems to be a python script by itself and it has the shebang (#!/usr/bin/python3), so the ipython is not a standalone binary, but it gets life because of some python. So as that ipython script itself needs some python to run it, so you run the ipython module directly using some python of your choice instead of letting that /usr/local/bin/ipython to decide it for you, and that is the fix for the problem of ‘what python ipython uses’.
Following ipython reads wrong python version, in /usr/local/bin/ipython, I simply changed
#!/usr/bin/python3
in the first line to
#!/usr/bin/python
and Python 2 has become the default version used by iPython:
kurt#kurt-ThinkPad:~$ ipython
Python 2.7.12 (default, Jul 1 2016, 15:12:24)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
now IPython 6.0+ does not support Python 2.6, 2.7, 3.0, 3.1, or 3.2.
When using Python 2.7, please install IPython 5.x LTS Long Term Support version.
Beginning with IPython 6.0, Python 3.3 and above is required.
I select what python version execute by means of py, like this:
py -2.7 -m IPython
where 2.7 is the version I need.
Following cel's second solution (for non-Anaconda users) on Using both Python 2.x and Python 3.x in IPython Notebook, I set up two virtual environments for Python 2 and Python 3, and installed iPython separately on each.
I installed julia and am using some nice python packages like matplotlib in julia using PyCall. I have installed all python stuff with anaconda and used python 3.4. I am able to switch from enviroment in anaconda to use python 2.7.
The thing is that I would like to import openCV as a python package in julia but it only runs with python 2.7. So I was wondering if it was possible to use python 2.7 in julia trough anaconda while python 3.4 was in anaconda's main install.
A working option would be to reinstall anaconda with version 2.7, but I don't want that.
Thanks in advance,
Frank
Current Anaconda installation
OpenCV3 on Python3
The thing is that I would like to import openCV as a python package in julia but it only runs with python 2.7.
Have you tried installing OpenCV3 with your Anaconda Python version 3.x installation?
conda install -c https://conda.anaconda.org/menpo opencv3
Add another Python 2.7 environment
You could also create new Anaconda Python environment with Python 2.7 installed using your current Anaconda install with conda create:
conda create -n py27 python=2.7 anaconda
Assuming you are using the full Anaconda distribution, I understand this will install a full Anaconda Python 2.7 environment (see miniconda, below), but it will not mess up your previous Anaconda Python 3 env.
http://conda.pydata.org/docs/py2or3.html#install-a-different-version-of-python
Conda.jl Julia package
You could use Conda.jl for managing Julia binary dependencies:
This package allows one to use conda as a binary provider for Julia. While other binary providers like Hombrew.jl, AptGet.jl or WinRPM.jl are platform-specific, Conda.jl is a cross-platform alternative. It can also be used without administrator rights, in contrast to the current Linux-based providers.
conda is a package manager which started as the binary package manager for the Anaconda Python distribution, but it also provides arbitrary packages. Instead of the full Anaconda distribution, Conda.jl uses the miniconda Python environment, which only includes conda and its dependencies.
You can install it by running Pkg.add("Conda") at the Julia prompt.
Install and load Conda.jl:
julia> # Pkg.add("Conda")
julia> using Conda
Search for the package:
julia> Conda.search("opencv")
1-element Array{AbstractString,1}:
"opencv"
Install the package:
julia> Conda.add("opencv")
Fetching package metadata: ....
Solving package specifications: ....................
Package plan for installation in environment /home/ismaelvc/.julia/v0.4/Conda/deps/usr:
The following packages will be downloaded:
package | build
---------------------------|-----------------
jpeg-8d | 0 699 KB
wheel-0.29.0 | py27_0 81 KB
opencv-2.4.10 | np110py27_1 9.2 MB
------------------------------------------------------------
Total: 10.0 MB
The following NEW packages will be INSTALLED:
jpeg: 8d-0
opencv: 2.4.10-np110py27_1
The following packages will be UPDATED:
wheel: 0.26.0-py27_1 --> 0.29.0-py27_0
Fetching packages ...
jpeg-8d-0.tar. 100% |##########| Time: 0:00:01 652.02 kB/s
wheel-0.29.0-p 100% |##########| Time: 0:00:00 336.94 kB/s
opencv-2.4.10- 100% |##########| Time: 0:00:10 962.48 kB/s
Extracting packages ...
[ COMPLETE ]|##########| 100%
Unlinking packages ...
[ COMPLETE ]|##########| 100%
Linking packages ...
[ COMPLETE ]|##########| 100%
Total: 10.0 MB
Check that it worked:
shell> .julia/v0.4/Conda/deps/usr/bin/python
Python 2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import cv2
>>> cv2.__version__
'2.4.10'
>>>
Within Julia via PyCall:
julia> using PyCall # Pkg.add("PyCall")
julia> #pyimport cv2
julia> #pyimport sys
julia> sys.version |> println
2.7.11 |Continuum Analytics, Inc.| (default, Dec 6 2015, 18:08:32)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)]
julia> import Conda
julia> Conda.PYTHONDIR
"/home/ismaelvc/.julia/v0.4/Conda/deps/usr/bin"
Specify the python version for PyCall
https://github.com/stevengj/PyCall.jl#specifying-the-python-version
Miniconda
Or use miniconda for Python 2.7 directly:
http://conda.pydata.org/miniconda.html
Conda.jl installs by default the Python version 2.7.x miniconda (installing everything in ~/.julia/v0.x/Conda).
In Linux:
It is often very easy to install only the things you want, without having to use Anaconda (I'm assuming you use Mac or PC, but still useful to others), example uses ArchLinux package manager pacman, it's similar with other Linux distributions package managers like: yum, zipper, apt-get, etc:
shell> sudo pacman -S opencv
warning: opencv-2.4.12.2-2 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...
Package (1) Old Version New Version Net Change Download Size
extra/opencv 2.4.12.2-2 2.4.12.2-2 0.00 MiB 7.10 MiB
Total Download Size: 7.10 MiB
Total Installed Size: 38.86 MiB
Net Upgrade Size: 0.00 MiB
:: Proceed with installation? [Y/n] n
shell> python2
Python 2.7.11 (default, Dec 6 2015, 15:43:46)
[GCC 5.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'2.4.12.2'
>>>
I am trying to install Python 3.5.0 alongside with Python 2.7.4.
C:\Users\Animesh>python
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py -2
Python 2.7.4 (default, Apr 6 2013, 19:55:15) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
C:\Users\Animesh>py -3
Fatal Python error: Py_Initialize: unable to load the file system codec
File "E:\Python27\Lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Current thread 0x00003514 (most recent call first):
I tried a bunch of commands as shown above but python 3.5 does not seem to work. I even tried creating a project on PyCharm using the Python 3.5 interpreter but it gives that same error.
How should I rectify this error?
The official installer for Python will install 3.5 in C:\Program Files\Python 3.5.
It will automatically add this path to your PATH variable (if you tell it). It seems like you did not enable this option.
In your PATH (not PYTHONPATH) setting.
You can get to this by going to the Settings application and searching for environment, then clicking on "Edit environment variables for your account" - this will open a properties window; click Environment Variables on the bottom to load the settings for your account.
You need to add the path manually to the PATH variable, and remove the E:\Python2.7 path.
Do this, then restart your command prompt and the default Python version will be 3.5.
For PyCharm, you can just add a new local interpreter in settings (CTRL+ALT+S) and point it directly to the location where you installed Python 3.5.
Since both interpreters are named python.exe, the first one found in your PATH will be executed. In practical terms this means, whatever is in your PATH is the default Python for your system. To execute the other version, you need to point to it explicitly.
If you have Python 2.7 in E:\Python2.7 and Python 3.5 in C:\Program Files\Python 3.5, pick the one you want to be the default and add the path to it in your PATH environment variable - you can always refer to the other installation by typing the full path to the python.exe file.
C:\>python.exe # this will launch whatever is found first in your `PATH`
C:\>E:\Python2.7\python.exe # explicitly launch the 2.7 version.
As far as PyCharm is concerned, it will read PATH and pick up the default interpreter, you can add the other one in your settings by browsing to its location.
Then, when creating a new project, you can pick which version you want to work with.
I just installed Lubuntu 12.10 on a new laptop, and I'm trying to get Django working. I installed it from Synaptic Package Manager, and when I try to make a sample project on the command line, this is what I get:
amanda#amanda-ThinkPad-E420:~$ django-admin.py startproject caltrain
django-admin.py: command not found
And I verified Django is installed correctly,
amanda#amanda-ThinkPad-E420:~$ python
Python 2.7.3 (default, Sep 26 2012, 21:51:14)
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> print(django.get_version())
1.4.1
>>>
Is this some sorta path issue or something? I don't remember having this issue on my Mac, but again I'm not very Unix savvy to begin with.
This information may be a bit stale, but I found this information that seems similar to your problem: http://ubuntuforums.org/showthread.php?t=1267372
With this solution:
Name of "django-admin.py" was changed to "django-admin" in /usr/bin directory in the python-django package.
To get around this I just created a symbolic link to django-admin named django-admin.py.
ln -s /usr/bin/django-admin /usr/bin/django-admin.py (as root)
Hope this helps, but again this was written in 2009.
You should see this. it contains details concerning problems with django-admin.py location
https://docs.djangoproject.com/en/1.6/faq/troubleshooting/#troubleshooting-django-admin-py