Pandas import issues - python-2.7

I have successfully installed Pandas through Anaconda in PyCharm. Unfortunately when I run Import Pandas this is what I get as the output:
/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7
"/Users/PycharmProjects/Security upload/Security
upload.py"
Traceback (most recent call last):
File "/Users/PycharmProjects/Security upload/Security
upload.py", line 3, in <module>
import pandas
File "/Users/Library/Python/2.7/lib/python/site-
packages/pandas/__init__.py", line 23, in <module>
from pandas.compat.numpy import *
File "/Users/Library/Python/2.7/lib/python/site-
packages/pandas/compat/__init__.py", line 361, in <module>
from dateutil import parser as _date_parser
File "/Users/Library/Python/2.7/lib/python/site-
packages/dateutil/parser.py", line 43, in <module>
from . import tz
File "/Users/Library/Python/2.7/lib/python/site-
packages/dateutil/tz/__init__.py", line 1, in <module>
from .tz import *
File "/Users/Library/Python/2.7/lib/python/site-
packages/dateutil/tz/tz.py", line 23, in <module>
from ._common import tzname_in_python2, _tzinfo, _total_seconds
File "/Users/Library/Python/2.7/lib/python/site-
packages/dateutil/tz/_common.py", line 2, in <module>
from six.moves import _thread
ImportError: cannot import name _thread
Could someone provide some insight on how to approach a solution?

According to here and here, you need to fix your dateutil package.
pip uninstall python-dateutil
pip install python-dateutil --upgrade
Maybe this:
sudo pip uninstall python-dateutil
sudo pip install python-dateutil==2.2

Was facing the same issue and started installing jupyter and got few errors
reinstalling ipython worked for me
sudo -H pip install --ignore-installed -U ipython
I also needed to reinstall pyzmq
sudo -H pip install --ignore-installed -U pyzmq
after this I re-ran import pandas in ipython and it worked

Related

Django command - django-admin command not working

i have tried to install django using below three command. Now when i execute the django-amdin command then its showing me below error. Even i cant see the django-admin --version.
sudo apt install python3.8
sudo apt-get install python3-pip
pip3 install Django ( Its successfully installed )
Now when i execute any command related to django-admin then its showing below error:
Error is :
Traceback (most recent call last):
File "/home/dev/.local/bin/django-admin", line 7, in <module>
from django.core.management import execute_from_command_line
File "/home/dev/.local/lib/python3.5/site-packages/django/core/management/__init__.py", line 13, in <module>
from django.apps import apps
File "/home/dev/.local/lib/python3.5/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig
File "/home/dev/.local/lib/python3.5/site-packages/django/apps/config.py", line 7, in <module>
from django.utils.deprecation import RemovedInDjango41Warning
File "/home/dev/.local/lib/python3.5/site-packages/django/utils/deprecation.py", line 5, in <module>
from asgiref.sync import sync_to_async
File "/home/dev/.local/lib/python3.5/site-packages/asgiref/sync.py", line 114
launch_map: "Dict[asyncio.Task[object], threading.Thread]" = {}
^
SyntaxError: invalid syntax
Please help here if anyone have an idea.
I found an answer to this question since I had the same problem, my Django version required python 3.6+. I don't know how he found that out but it solved it for me.
link to answer
by commenter Siddhartha Dutta
"Python 3.5.6 will not work, you will need at least Python3.6+ in your virtual environment, for this Django version. –
Siddhartha Dutta
May 25 at 14:21"
you can uninstall asgiref first:
python3 -m pip uninstall asgiref
and install django again:
python3 -m pip install django

Getting "No module named queue" when installing tensorflow

I am using Anaconda and trying to install tensorflow with pip, but I receive the following error and I am not sure what to do next?
Traceback (most recent call last):
File "/home/xieyangyang/anaconda3/envs/tensorflow1/bin/pip", line 7, in <module>
from pip._internal import main
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_internal/__init__.py", line 20, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/xieyangyang/anaconda3/envs/tensorflow1/lib/python2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 44, in <module>
from .util.queue import LifoQueue
ImportError: No module named queue
Maybe just reinstall pip without pip?
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
See https://pip.pypa.io/en/stable/installing/ for more info.

Could not find the GDAL library (tried "gdal202", "gdal201", "gdal20", "gdal111", "gdal110", "gdal19")

I am working on a django project, trying to use GeoDjango.
In my setting.py, I added 'django.contrib.gis',to installed app but getting this error.
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in <module>
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in <module>
from django.contrib.gis.admin.widgets import OpenLayersWidget
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\admin\widgets.py", line 3, in <module>
from django.contrib.gis.gdal import GDALException
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\gdal\__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\gdal\datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\gdal\driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\gdal\prototypes\ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "C:\Users\lenovo\AppData\Local\conda\conda\envs\myDjangoEnv\lib\site-packages\django\contrib\gis\gdal\libgdal.py", line 43, in <module>
% '", "'.join(lib_names)
django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal202", "gdal201", "gdal20", "gdal111", "gdal110", "gdal19"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.
I have no idea what the error is all about. Could anyone help me out.
https://docs.djangoproject.com/en/2.1/ref/contrib/gis/install/geolibs
On Debian/Ubuntu, you are advised to install the following packages which will install, directly or by dependency, the required geospatial libraries:
$ sudo apt-get install binutils libproj-dev gdal-bin
install the below library
apt-get -y update && \
apt-get -y install \
python-gdal \
python-geoip \
rpl
python version 2.7
pip install django
pip install psycopg2
pip install pyproj
found the gdal wheel here https://www.lfd.uci.edu/~gohlke/pythonlibs/#gdal
pip install \gdal wheel
add 2 system environment variables "GDAL_DATA" and "GDAL_LIB".
GDAL_DATA = C:\python27\Lib\site-packages\osgeo\data\gdal
GDAL_LIB = C:\python27\Lib\site-packages\osgeo
Then add %GDAL_DATA% and %GDAL_LIB% to your system PATH
go open %PYTHONPATH%\Lib\site-packages\django\contrib\gis\gdal\ libgdal.py and add str('gdal202') to line 26.
lib_names = [str('gdal201'), str('gdal202'), str('gdal111'), str('gdal110'), str('gdal19')]

Theano ImportError: cannot import name inplace_increment

I've installed Theano as such:
(python2) bash-3.2$ sudo pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git
I'm using conda with Python 2.7. The python2 in parentheses is my conda environment. I'm trying to run the code from iGAN: https://github.com/junyanz/iGAN. I'm on OS X 10.11.6.
The error I get is ImportError: cannot import name inplace_increment. I've tried manually removing the Theano cache (as described in https://github.com/Theano/Theano/issues/5564) and the same error still arises. (I can't use theano-cache purge because it requires installing a version of scipy that clashes with the version required by OpenCV.) I've also tried uninstalling and reinstalling Theano via pip and still get the same error. Any suggestions?
Here's the context:
(python2) bash-3.2$ python iGAN_main.py
//anaconda/envs/python2/lib/python2.7/site-packages/numpy/lib/utils.py:254: FutureWarning: Numpy has detected that you (may be) writing to an array returned
by numpy.diagonal or by selecting multiple fields in a record
array. This code will likely break in the next numpy release --
see numpy.diagonal or arrays.indexing reference docs for details.
The quick fix is to make an explicit copy (e.g., do
arr.diagonal().copy() or arr[['f0','f1']].copy()).
ai = a.__array_interface__
Traceback (most recent call last):
File "iGAN_main.py", line 9, in <module>
import constrained_opt
File "/Users/.../Desktop/Code/iGAN/constrained_opt.py", line 3, in <module>
from lib.rng import np_rng
File "/Users/.../Desktop/Code/iGAN/lib/rng.py", line 2, in <module>
from theano.sandbox.rng_mrg import MRG_RandomStreams as RandomStreams
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/__init__.py", line 102, in <module>
from theano.scan_module import (scan, map, reduce, foldl, foldr, clone,
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/__init__.py", line 41, in <module>
from theano.scan_module import scan_opt
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/scan_module/scan_opt.py", line 60, in <module>
from theano import tensor, scalar
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/__init__.py", line 9, in <module>
from theano.tensor.subtensor import *
File "//anaconda/envs/python2/lib/python2.7/site-packages/theano/tensor/subtensor.py", line 27, in <module>
from cutils_ext.cutils_ext import inplace_increment
ImportError: cannot import name inplace_increment
I had the same problem.
Deleting the cache manually worked.
rm -rf ~/.theano
If that doesn't help try installing from source.
python setup.py install

Install Django using setup file in Python 2.7

I am trying to install Diango via setup up file then it shows the following error:
hari#hari-HP-Pavilion-g6-Notebook-PC:~/Downloads/django-master$ sudo python setup.py install
Traceback (most recent call last):
File "setup.py", line 32, in <module>
version = __import__('django').get_version()
File "/home/hari/Downloads/django-master/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/hari/Downloads/django-master/django/utils/version.py", line 60, in <module>
#functools.lru_cache()
AttributeError: 'module' object has no attribute 'lru_cache'
How to fix this error?
Maybe the zip file from github is only for windows, but i see that you are using linux so:
1) Use PIP (Use sudo as you are not inside virtualenv)
sudo pip install Django==1.10.6
2) Use GIT
git clone https://github.com/django/django.git
Hope this help
I have the same problem when install Diango
then I use this in cmd
>>>> import functools
>>> dir(functools)
['WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', '__builtins__', '__doc__', '__file__'
, '__name__', '__package__', 'cmp_to_key', 'partial', 'reduce', 'total_ordering'
, 'update_wrapper', 'wraps']
you can see there is not lru_cache..so, I think this is the reason..
then I installed Python3.6.1
>>> import functools
>>> dir(functools)
['MappingProxyType', 'RLock', 'WRAPPER_ASSIGNMENTS', 'WRAPPER_UPDATES', 'WeakKey
Dictionary', '_CacheInfo', '_HashedSeq', '__all__', '__builtins__', '__cached__'
, '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_
c3_merge', '_c3_mro', '_compose_mro', '_convert', '_find_impl', '_ge_from_gt', '
_ge_from_le', '_ge_from_lt', '_gt_from_ge', '_gt_from_le', '_gt_from_lt', '_le_f
rom_ge', '_le_from_gt', '_le_from_lt', '_lru_cache_wrapper', '_lt_from_ge', '_lt
_from_gt', '_lt_from_le', '_make_key', 'cmp_to_key', 'get_cache_token', 'lru_cache', 'namedtuple', 'partial', 'partialmethod', 'recursive_repr', 'reduce', 'sing
ledispatch', 'total_ordering', 'update_wrapper', 'wraps']
you can see lru_cache there, I wish it's helpful for you (sorry for my English, I'm not good at this..)