I have default and anaconda python, theano is installed in conda moreover it was also part of anaconda for keras. I am trying to exec a python file from another folder as python ---- and everything is ok except from theano.tensor.fft import ifft where it says no module named theano.tensor.fft I have added PYTHONPATH I have separately added theano in site-package but i can not figure out why it can not import module, please note that I can import theano.tensor I am trying to run MarcBS/keras caffe2keras.py
this is what I got when trying to install theano
Traceback (most recent call last):
File "/usr/local/bin/pip", line 7, in <module>
from pip import main
File "/usr/local/lib/python2.7/dist-packages/pip/__init__.py", line 11, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/local/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 22, in <module>
from pip._vendor import requests, six
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/__init__.py", line 53, in <module>
from .packages.urllib3.contrib import pyopenssl
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 70, in <module>
ssl.PROTOCOL_SSLv3: OpenSSL.SSL.SSLv3_METHOD,
AttributeError: 'module' object has no attribute 'PROTOCOL_SSLv3'
Related
I want to import the "genism" library. I have previously successfully installed it by typing the following in the command prompt:
pip install gensim
However, the following error appears when importing it:
Traceback (most recent call last):
File "C:/Users/PycharmProjects/untitled/file.py", line 3, in <module>
import gensim
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\__init__.py", line 5, in <module>
from gensim import parsing, corpora, matutils, interfaces, models, similarities, summarization, utils # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\__init__.py", line 4, in <module>
from .preprocessing import (remove_stopwords, strip_punctuation, strip_punctuation2, # noqa:F401
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\parsing\preprocessing.py", line 42, in <module>
from gensim import utils
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\gensim\utils.py", line 40, in <module>
import scipy.sparse
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\__init__.py", line 156, in <module>
from . import fft
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\__init__.py", line 76, in <module>
from ._basic import (
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\fft\_basic.py", line 1, in <module>
from scipy._lib.uarray import generate_multimethod, Dispatchable
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\uarray.py", line 27, in <module>
from ._uarray import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\__init__.py", line 114, in <module>
from ._backend import *
File "C:\Users\AppData\Local\Programs\Python\Python35\lib\site-packages\scipy\_lib\_uarray\_backend.py", line 1, in <module>
from typing import (
ImportError: cannot import name 'Type'
I have also previously successfully installed the "typing" library":
pip install typing
What should I do?
It is because Python 3.5 has its own version typing, and it is incompatible with the installed version of gensim. Upgrade to python3.6 could solve the problem.
When using virtualenv in VSCode integrated terminal I get the following error when trying to use pip or pip3
Traceback (most recent call last):
File "/home/me/repo/py-hello/venv/bin/pip3", line 5, in <module>
from pip._internal.cli.main import main
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 25, in <module>
from pip._internal.locations import USER_CACHE_DIR, get_src_prefix
File "/usr/lib/python3/dist-packages/pip/_internal/locations.py", line 19, in <module>
from pip._internal.utils import appdirs
File "/usr/lib/python3/dist-packages/pip/_internal/utils/appdirs.py", line 13, in <module>
from pip._vendor import appdirs as _appdirs
ImportError: cannot import name 'appdirs' from 'pip._vendor' (/usr/lib/python3/dist-packages/pip/_vendor/__init__.py)
However, this isn't the case when using a regular terminal. I can run pip fine.
I found a few mentions in other posts here and here but neither are helping me.
I am trying to use tensorflow for research in my macbook. I use pip3 to install tensorflow in the system (not in virtual environment).
At first, I just want to verify tensorflow can be correctly imported via python3 in terminal. However, sometimes, I got the following problem when importing.
>>>import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "/Users/cyan/Library/Python/3.5/lib/python/site-packages/tensorflow/python/__init__.py", line 47, in <module>
import numpy as np
File "/Library/Python/2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/Library/Python/2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Python/2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/Library/Python/2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/Library/Python/2.7/site-packages/numpy/core/__init__.py", line 14, in <module>
from . import multiarray
ImportError: dlopen(/Library/Python/2.7/site-packages/numpy/core/multiarray.so, 2): Symbol not found: _PyBuffer_Type
Referenced from: /Library/Python/2.7/site-packages/numpy/core/multiarray.so
Expected in: flat namespace in /Library/Python/2.7/site-packages/numpy/core/multiarray.so
This error could only be solved if I ran the following code firstly before python3 execution
unset PYTHONPATH
If I didn't unset PYTHONPATH, I also found errors when checking the version of pip3 using
pip3 --version
The errors are shown as follows.
>> pip3 --version
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 6, in <module>
from pip._internal import main
File "/Library/Python/2.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 11, in <module>
from .exceptions import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/exceptions.py", line 2, in <module>
from .packages.six.moves.http_client import (
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 203, in load_module
mod = mod._resolve()
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/Library/Python/2.7/site-packages/pip/_vendor/urllib3/packages/six.py", line 82, in _import_module
__import__(name)
File "/Library/Python/2.7/site-packages/http/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
I thought it was so inconvenient to unset PYTHONPATH every time, so is there any solutions for this problem? I also want to import tensorflow in other text editor, such as Sublime and Pycharm, so I was really not sure what to do next.
I tried the same scenario. It is working fine for me. In the first error it seems your python installation is messed up. If you are using python3 in terminal, it should not refer to 2.7 libraries.
Also I dont think you require unset PYTHONPATH everytime. First thing is you dont need to setup PYTHONPATH. It seems the installation got issue.
You using homebrew in mac to install packages. If not I will say use homebrew and it will work as charm. As it adds dependency properly.
Thanks,
Ashish
I am trying to run some C++ code with embedded Python. Code was working completely fine a couple of weeks ago. The code still compiles, but I am now getting the error
Traceback (most recent call last):
File "./main.py", line 1, in <module>
import numpy as np
File "/usr/local/lib/python2.7/site-packages/numpy/__init__.py", line 142, in <module>
from . import add_newdocs
File "/usr/local/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/site-packages/numpy/lib/__init__.py", line 8, in <module>
from .type_check import *
File "/usr/local/lib/python2.7/site-packages/numpy/lib/type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "/usr/local/lib/python2.7/site-packages/numpy/core/__init__.py", line 74, in <module>
from numpy.testing.nosetester import _numpy_tester
File "/usr/local/lib/python2.7/site-packages/numpy/testing/__init__.py", line 10, in <module>
from unittest import TestCase
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/__init__.py", line 64, in <module>
from .main import TestProgram, main
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/main.py", line 7, in <module>
from . import loader, runner
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/runner.py", line 7, in <module>
from .signals import registerResult
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/unittest/signals.py", line 2, in <module>
import weakref
File "/usr/local/opt/python/Frameworks/Python.framework/Versions/2.7/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Since then the only change I have made is to install the macOS Supplemental Update and to upgrade Python from 2.7.13_1 to 2.7.14_2 (using Homebrew). I have changed the relevant linker flags in the makefile, i.e. those that appear when I type python-config --ldflags. I have also made sure that the Python I am using is definitely the Homebrew one by inserting export PATH="/usr/local/opt/python/libexec/bin:$PATH" into my .bash_profile as directed by Homebrew.
I am not sure whether this error is because of the Python update, the recent macOS Supplemental Update, or something else. Any idea what the problem could be?
Thanks
I had the same problem;
In python 2.7 the NumPy 1.8.0 was available,
Then I installed NumPy (again) using brew, and it wasn't available in my python (2.7) anymore. (Got the same error you got here)
So I did "brew unlink python && brew link python" to use python 3 (instead of 2) which NumPy 1.14 is available in it.
I guess the python 2.7 was not compatible with this recent version of NumPy.
After installing prospector by using pip install prospector, I execute this command.
prospector --version
I got this error
Traceback (most recent call last):
File "/home/ec2-user/ingestion/acadenv/bin/prospector", line 7, in <module>
from prospector.run import main
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/prospector/run.py", line 8, in <module>
from prospector import blender, postfilter, tools
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/prospector/tools/__init__.py", line 7, in <module>
from prospector.tools.pylint import PylintTool
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/prospector/tools/pylint/__init__.py", line 6, in <module>
from pylint.config import find_pylintrc
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/pylint/config.py", line 48, in <module>
from pylint import utils
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/pylint/utils.py", line 39, in <module>
from astroid import nodes, Module
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/astroid/__init__.py", line 54, in <module>
from astroid.nodes import *
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/astroid/nodes.py", line 39, in <module>
from astroid.node_classes import (
File "/home/ec2-user/ingestion/acadenv/local/lib/python2.7/dist-packages/astroid/node_classes.py", line 24, in <module>
import lazy_object_proxy
ImportError: No module named lazy_object_proxy
Moreover I have executed pip install lazy_object_proxy but this does not solve the problem also.