I've been using PyCharm CE with pretty great success. But I just installed the basemap module (having to compile geos and basemap from source) and it seems to have broken the PyCharm interpreter. All of my modules load properly when I run Python from the terminal, and all of my modules run properly when I run Python from the terminal WITHIN PyCharm, but now when I attempt to load certain packages from the interactive interpreter, I get error messages. For example, now when I try to import pandas in the interactive interpreter, I get this:
Traceback (most recent call last):
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-3-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 25, in <module>
import pandas.core.config_init
File "/Library/Python/2.7/site-packages/pandas/core/config_init.py", line 4, in <module>
from pandas.core.format import detect_console_encoding
File "/Library/Python/2.7/site-packages/pandas/core/format.py", line 12, in <module>
from pandas.core.index import Index, MultiIndex, _ensure_index
File "/Library/Python/2.7/site-packages/pandas/core/index.py", line 10, in <module>
import pandas.index as _index
File "index.pyx", line 34, in init pandas.index (pandas/index.c:14957)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pytz/__init__.py", line 31, in <module>
from pkg_resources import resource_stream
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <module>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 682, in subscribe
callback(dist)
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2717, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 2255, in activate
list(map(declare_namespace, self._get_metadata('namespace_packages.txt')))
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pkg_resources.py", line 1851, in declare_namespace
path = sys.modules[parent].__path__
KeyError: 'dap'
If I try to import pandas again, in the same session, the error message changes to this:
Traceback (most recent call last):
cannot import name hashtable
File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/IPython/core/interactiveshell.py", line 2827, in run_code
exec code_obj in self.user_global_ns, self.user_ns
File "<ipython-input-6-af55e7023913>", line 1, in <module>
import pandas as pd
File "/Library/Python/2.7/site-packages/pandas/__init__.py", line 6, in <module>
from . import hashtable, tslib, lib
ImportError: cannot import name hashtable
What did I do to break the interpreter? I tried reinstalling PyCharm to reset and it didn't seem to work.
I case this helps anyone. I had this issue in a Django project that also was setup to use Google App Engine; therefore, PyCharm loaded the GAE version of many Python packages (they were being added to my PYTHONPATH). I disabled Google App Engine support in File -> Settings -> Languages & Frameworks -> Google App Engine. The problem went away.
Note: I did not have the Pandas import issue when running my Django app outside of PyCharm.
Related
Cannot able to execute the command cqlsh in mac m1 based system.
% bin/cqlsh
Traceback (most recent call last):
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/cqlsh.py", line 159, in <module>
from cqlshlib import cql3handling, cqlhandling, pylexotron, sslhandling, cqlshhandling
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cql3handling.py", line 19, in <module>
from cqlshlib.cqlhandling import CqlParsingRuleSet, Hint
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/cqlhandling.py", line 23, in <module>
from cqlshlib import pylexotron, util
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 342, in <module>
class ParsingRuleSet:
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/pylexotron.py", line 343, in ParsingRuleSet
RuleSpecScanner = SaferScanner([
^^^^^^^^^^^^^^
File "/Users/avinashkasukurthi/devtools/apache-cassandra-4.0.7/bin/../pylib/cqlshlib/saferscanner.py", line 91, in __init__
s = re.sre_parse.State()
^^^^^^^^^^^^
AttributeError: module 're' has no attribute 'sre_parse'
Looks like there may have been a breaking change introduced to Python's synchronized regex engine (SRE) with Python 3.11. I have created a ticket for this on the Cassandra project (CASSANDRA-18088).
In the interim, downgrade your local Python to 3.10, and you should be fine.
When I'm trying to install any package using PyCharm terminal, I always get this error.
(venv) C:\Users\Mi\Desktop\MAIN\Coding\python>pip install PyMySQL
Traceback (most recent call last):
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\Scripts\pip-script.py",
line 11, in <module>
load_entry_point('pip==19.0.3', 'console_scripts', 'pip')()
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 489, in load_entry_point
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2793, in load_entry_point
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2411, in load
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\setupt
ools-40.8.0-py3.7.egg\pkg_resources\__init__.py", line 2417, in resolve
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\main_parser.py", line 12, in <module>
from pip._internal.commands import (
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\commands\__init__.py", line 6, in <module>
from pip._internal.commands.completion import CompletionCommand
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\commands\completion.py", line 6, in <module>
from pip._internal.cli.base_command import Command
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\cli\base_command.py", line 20, in <module>
from pip._internal.download import PipSession
File "C:\Users\Mi\Desktop\MAIN\Coding\python\Coursera\venv\lib\site-packages\pip-19
.0.3-py3.7.egg\pip\_internal\download.py", line 6, in <module>
from json import json
ImportError: cannot import name 'json' from 'json' (C:\Users\Mi\Anaconda3\lib\json\__
init__.py)
But when I use pip install the library is installed, but it still doesn't work in PyCharm.
Thanks for help! And sorry for my english.
you can try to download corresponding pacages in '.tar.gz' format on this link
manually unzip it
enter the unzipped folder
install the package through the following cmd command:
python setup.py install
here I suppose you are using windows and your python is above 3
If you are continuously encontering this problem,I suggest you alter the original download channel to a mirror.
If you installed the library through terminal and Pycharm still doesn't recognize the library, I think may be you should select the correct interpreter for the project by clicking the project interpreter at the bottom right in a Pycharm project. Look at the image in this
link. Click on the Interpreter which is named just "Python 3.x", it may work then.
["3.x" as in which version of python you are using]
>>> import nltk
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/__init__.py", line 89, in <module>
from nltk.internals import config_java
File "/Users/hexialong/anaconda3/lib/python3.6/site-packages/nltk/internals.py", line 11, in <module>
import subprocess
File "/Users/hexialong/anaconda3/lib/python3.6/subprocess.py", line 138, in <module>
import selectors
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 290, in <module>
class SelectSelector(_BaseSelectorImpl):
File "/Users/hexialong/anaconda3/lib/python3.6/selectors.py", line 317, in SelectSelector
_select = select.select
AttributeError: module 'select' has no attribute 'select'
My environment is MacOS and python version is 3.6
select is a Python standard module. Maybe you should check that your python binaries are unbroken or just reinstall it.
Check that:
import select and select.select in Python Interactive Environment. If some errors generated, you'd better reinstall the python binaries.
Super new to coding and i'm trying to learn Python. I have used Anaconda to manage packages, etc. I typically update Anaconda/conda in cmd with commands such as conda update conda or conda update anaconda
As of late, when using these commands, it comes up with a message: "ImportError: No module named 'Requests.exceptions'" followed by "Import Error: cannot import name 'Session'" Please see below.
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 171, in main
activate.main()
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\activate.py", line 181, in main
from ..install import symlink_conda
File "C:\Program Files\Anaconda3\lib\site-packages\conda\install.py", line 37, in <module>
from .core.package_cache import rm_fetched # NOQA
File "C:\Program Files\Anaconda3\lib\site-packages\conda\core\package_cache.py", line 9, in <module>
from .path_actions import CacheUrlAction, ExtractPackageAction
File "C:\Program Files\Anaconda3\lib\site-packages\conda\core\path_actions.py", line 33, in <module>
from ..gateways.download import download
File "C:\Program Files\Anaconda3\lib\site-packages\conda\gateways\download.py", line 10, in <module>
from requests.exceptions import ConnectionError, HTTPError, InvalidSchema, SSLError
ImportError: No module named 'requests.exceptions'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Program Files\Anaconda3\Scripts\conda-script.py", line 10, in <module>
sys.exit(main())
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main.py", line 179, in main
return handle_exception(e)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 634, in handle_exception
print_unexpected_error_message(e)
File "C:\Program Files\Anaconda3\lib\site-packages\conda\exceptions.py", line 596, in print_unexpected_error_message
stderrlogger.info(get_main_info_str(get_info_dict()))
File "C:\Program Files\Anaconda3\lib\site-packages\conda\cli\main_info.py", line 162, in get_info_dict
from ..connection import user_agent
File "C:\Program Files\Anaconda3\lib\site-packages\conda\connection.py", line 12, in <module>
from requests import Session, __version__ as REQUESTS_VERSION
ImportError: cannot import name 'Session'
I've tried using commands like pip install requests but it says that it has already says "Requirement already satisfied and lists locations where it is installed (i am guessing).
At this point I can't even get a response back from conda commands like conda info --envs. It doesn't do anything when i type that in.
If i need to uninstall conda/anaconda i will but am i just missing a simple fix?
Thanks friends!
You should install requests with conda if you plan to use conda as your python environment.
conda install requests
I am on OSX 10.10.3 with Python 2.7.6 as my main Python. I suddenly ran into trouble using pip, and tried to fix it. The solution proposed elsewhere on StackOverflow was to remove installations of pip and reinstall it either using their official installer or using easy_install.
Running the installation script (https://bootstrap.pypa.io/get-pip.py) gives:
Traceback (most recent call last):
File "pip.py", line 17767, in <module>
main()
File "pip.py", line 162, in main
bootstrap(tmpdir=tmpdir)
File "pip.py", line 82, in bootstrap
import pip
File "/tmp/tmpDnRtQK/pip.zip/pip/__init__.py", line 6, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 90, in <module>
from gettext import gettext
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 49, in <module>
import locale, copy, os, re, struct, sys
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 110, in <module>
#functools.wraps(_localeconv)
AttributeError: 'module' object has no attribute 'wraps'
and running "sudo easy_install pip" gives
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 7, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2793, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 673, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 581, in resolve
requirements.extend(dist.requires(req.extras)[::-1])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2323, in requires
dm = self._dep_map
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2374, in __getattr__
raise AttributeError(attr)
AttributeError: _dep_map
I am not really sure where to go next.
I am also in the situation that I can't import various modules, for example Flask, since I get the following error:
Traceback (most recent call last):
File "/Users/dawi/git/friends/run.py", line 2, in <module>
from application import app
File "/Users/dawi/git/friends/application/__init__.py", line 3, in <module>
from flask import Flask
File "/Library/Python/2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/__init__.py", line 17, in <module>
from werkzeug.exceptions import abort
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/__init__.py", line 154, in <module>
__import__('werkzeug.exceptions')
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/exceptions.py", line 71, in <module>
from werkzeug.wrappers import Response
File "/Library/Python/2.7/site-packages/Werkzeug-0.9.6-py2.7.egg/werkzeug/wrappers.py", line 23, in <module>
from functools import update_wrapper
ImportError: cannot import name update_wrapper