I am just starting to use pycharm. I want to use tabula-py, when I try to import tabula it gives me the following error:
import tabula
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/Applications/PyCharm
CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21,
in do_import
module = self._system_import(name, *args, **kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-
packages/tabula/__init__.py", line 1, in <module>
from .wrapper import read_pdf
File "/Applications/PyCharm
CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21,
in do_import
module = self._system_import(name, *args, **kwargs)
File
"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-
packages/tabula/wrapper.py", line 17, in <module>
import pandas as pd
File "/Applications/PyCharm
CE.app/Contents/helpers/pydev/_pydev_bundle/pydev_import_hook.py", line 21,
in do_import
module = self._system_import(name, *args, **kwargs)
ImportError: No module named pandas
and when i try to import pandas it's the same error. How do I fix this?
Output from pip:
Requirement already satisfied: pandas in /Users/Rexon/Library/Python/2.7/lib/python/site-packages Requirement already satisfied: numpy>=1.9.0 in /Users/Rexon/Library/Python/2.7/lib/python/site-packages (from pandas) Requirement already satisfied: python-dateutil in /Users/Rexon/Library/Python/2.7/lib/python/site-packages (from pandas) Requirement already satisfied: pytz>=2011k in /Users/Rexon/Library/Python/2.7/lib/python/site-packages (from pandas) Requirement already satisfied: six>=1.5 in /Users/Rexon/Library/Python/2.7/lib/python/site-packages (from python)
Your error says
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-
packages
But your pip says
/Users/Rexon/Library/Python/2.7/lib/python/site-packages
Make sure your terminal and pycharm use the same python path.
In Pycharm, go to preferences, and then project interpreter and click the '+' button to add the library to your project interpreter.
Your project $PYTHONPATH environment variable does not include the directory that pip installed your module to.
Related
I am running a .py file in google colab. Sometimes I can run it successfully but sometimes I get the error below. Can anyone help me fix this issue?
Traceback (most recent call last):
File "sculpt_faces.py", line 25, in <module>
from matplotlib.pyplot import cm
File "/usr/local/lib/python3.8/dist-packages/matplotlib/pyplot.py", line 2282, in <module>
switch_backend(rcParams["backend"])
File "/usr/local/lib/python3.8/dist-packages/matplotlib/pyplot.py", line 221, in switch_backend
backend_mod = importlib.import_module(backend_name)
File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/local/lib/python3.8/dist-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/usr/local/lib/python3.8/dist-packages/ipykernel/connect.py", line 18, in <module>
import jupyter_client
File "/usr/local/lib/python3.8/dist-packages/jupyter_client/__init__.py", line 4, in <module>
from .connect import *
File "/usr/local/lib/python3.8/dist-packages/jupyter_client/connect.py", line 28, in <module>
from jupyter_core.paths import jupyter_data_dir, jupyter_runtime_dir, secure_write
File "/usr/local/lib/python3.8/dist-packages/jupyter_core/paths.py", line 176, in <module>
deprecation(
File "/usr/local/lib/python3.8/dist-packages/jupyter_core/utils/__init__.py", line 87, in deprecation
warnings.warn(message, DeprecationWarning, stacklevel=stacklevel + 1)
DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
given by the platformdirs library. To remove this warning and
see the appropriate new directories, set the environment variable
`JUPYTER_PLATFORM_DIRS=1` and then run `jupyter --paths`.
The use of platformdirs will be the default in `jupyter_core` v6
This is the result of running "!pip install jupyter-core":
Looking in indexes: https://pypi.org/simple, https://us-python.pkg.dev/colab-wheels/public/simple/
Requirement already satisfied: jupyter-core in /usr/local/lib/python3.8/dist-packages (5.1.0)
Requirement already satisfied: traitlets>=5.3 in /usr/local/lib/python3.8/dist-packages (from jupyter-core) (5.6.0)
Requirement already satisfied: platformdirs>=2.5 in /usr/local/lib/python3.8/dist-packages (from jupyter-core) (2.5.4)
This warning tells you to set the environment variable.
On Linux this can be done running
export JUPYTER_PLATFORM_DIRS=1
to set a environment variable in a terminal.
Then run
jupyter --paths
in the terminal, too. Afterwards if you run your tests/code this warning should not appear.
New to programming. Installed Anaconda on a Windows 10 machine. Had some issues running updates.
While in Base environment, I installed my first Git repo successfully:
(base) C:\Users\samsung\Anaconda3\pkgs>pip install git+git://github.com/json-transformations/jsonflatten.git
Collecting git+git://github.com/json-transformations/jsonflatten.git
Cloning git://github.com/json-transformations/jsonflatten.git to c:\users\samsung\appdata\local\temp\pip-req-build-zeiezw
Running command git clone -q git://github.com/json-transformations/jsonflatten.git 'C:\Users\samsung\AppData\Local\Temp\p
Collecting jsoncut
Downloading jsoncut-0.6-py2.py3-none-any.whl (17 kB)
Requirement already satisfied: click>=6.0 in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten==0.2) (7.0)
Requirement already satisfied: colorama in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten==0.2) (0
Requirement already satisfied: pygments in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten==0.2) (2
Building wheels for collected packages: jsonflatten
Building wheel for jsonflatten (setup.py) ... done
Created wheel for jsonflatten: filename=jsonflatten-0.2-py2.py3-none-any.whl size=8116 sha256=029aafde944303cbfe872e86a13
Stored in directory: C:\Users\samsung\AppData\Local\Temp\pip-ephem-wheel-cache-so8173tt\wheels\8f\02\52\37295acfd1368a3d2
Successfully built jsonflatten
Installing collected packages: jsoncut, jsonflatten
Successfully installed jsoncut-0.6 jsonflatten-0.2
(base) C:\Users\samsung\Anaconda3\pkgs>pip install jsonflatten
Requirement already satisfied: jsonflatten in c:\users\samsung\anaconda3\lib\site-packages (0.2)
Requirement already satisfied: click>=6.0 in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten) (7.0)
Requirement already satisfied: jsoncut in c:\users\samsung\anaconda3\lib\site-packages (from jsonflatten) (0.6)
Requirement already satisfied: pygments in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten) (2.5.2)
Requirement already satisfied: colorama in c:\users\samsung\anaconda3\lib\site-packages (from jsoncut->jsonflatten) (0.4.3)
I then ran jsonflatten forecast.json as a test (as well as jsonflatten C:\Users\samsung.spyder-py3\forecast.json) as the readme suggests and got the output below. I ran from base as myenv (Python) spit out a message saying jsonflatten is not recognized as a command.
(base) C:\Users\samsung\.spyder-py3>jsonflatten C:\Users\samsung\.spyder-py3\forecast.json
Traceback (most recent call last):
File "c:\users\samsung\anaconda3\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\samsung\anaconda3\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\samsung\Anaconda3\Scripts\jsonflatten.exe\__main__.py", line 7, in <module>
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "c:\users\samsung\anaconda3\lib\site-packages\click\core.py", line 555, in invoke
return callback(*args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\click\decorators.py", line 17, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\samsung\anaconda3\lib\site-packages\jsonflatten\cli.py", line 63, in main
output(ctx, results, indent=4, is_json=True)
File "c:\users\samsung\anaconda3\lib\site-packages\jsoncut\cli.py", line 59, in output
output = highlighter.highlight_json(output)
File "c:\users\samsung\anaconda3\lib\site-packages\jsoncut\highlighter.py", line 53, in highlight_json
return pygments.highlight(d, JsonLexer(), formatter)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\__init__.py", line 85, in highlight
return format(lex(code, lexer), formatter, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\__init__.py", line 64, in format
formatter.format(tokens, realoutfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatters\terminal.py", line 101, in format
return Formatter.format(self, tokensource, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatter.py", line 95, in format
return self.format_unencoded(tokensource, outfile)
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\formatters\terminal.py", line 126, in format_unencoded
outfile.write(ansiformat(color, line.rstrip('\n')))
File "c:\users\samsung\anaconda3\lib\site-packages\pygments\console.py", line 68, in ansiformat
result.append(codes[attr])
KeyError: 'darkgray'
There is a guide for troubleshooting software in Anaconda: https://www.anaconda.com/what-to-do-when-things-go-wrong-in-anaconda/ but this is a brand-new install.
Does this look like an Anaconda issue, an issue with how I am running the software or an issue with the software itself?
You're getting an error in site-packages with a module that is a dependency of something that you've installed.
Anaconda is just a distribtion, not the runtime.
The problem is from Python's pygments\console.py module, which is likely responsible for coloring the output of your jsonflatten module.
Try to see if there is a CLI flag to not colorize stuff, or don't use jsonflatten and rather use python's json.tool or separately install jq instead. (not saying those offer what you need, but they also parse JSON on the CLI)
I have tried using sudo easy_install sqlalchemy, pip install sqlalchemy and pip install flask-sqlalchemy. I have also tried installing and uninstalling sqlalchemy and flask. I get the error
Traceback (most recent call last):
File "/usr/lib/python2.7/multiprocessing/process.py", line 267, in _bootstrap
self.run()
File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run
self._target(*self._args, **self._kwargs)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/hupper/worker.py", line 264, in worker_main
func(*spec_args, **spec_kwargs)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 40, in main
return command.run()
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/scripts/pserve.py", line 222, in run
app_spec, name=app_name, relative_to=base, global_conf=vars)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 247, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 272, in loadobj
return context.create()
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 710, in create
return self.object_type.invoke(self)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/loadwsgi.py", line 146, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/paste/deploy/util.py", line 55, in fix_call
val = callable(*args, **kw)
File "/home/j/Downloads/ng-website-master/ngse/__init__.py", line 15, in main
config.include('.models')
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 776, in include
c = self.maybe_dotted(callable)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/config/__init__.py", line 876, in maybe_dotted
return self.name_resolver.maybe_resolve(dotted)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 320, in maybe_resolve
return self._resolve(dotted, package)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 327, in _resolve
return self._zope_dottedname_style(dotted, package)
File "/home/j/Downloads/ng-website-master/venv/local/lib/python2.7/site-packages/pyramid/path.py", line 382, in _zope_dottedname_style
__import__(used)
File "/home/j/Downloads/ng-website-master/ngse/models/__init__.py", line 4, in <module>
import zope.sqlalchemy
ImportError: No module named sqlalchemy
Even after trying to upgrade sqlalchemy, I get the above error have.
Requirement already up-to-date: sqlalchemy in ./venv/lib/python2.7/site-packages
Tried upgrading flask-sqlalchemy,still get the same error
Requirement already up-to-date: flask-sqlalchemy in ./venv/lib/python2.7/site-packages
Requirement already up-to-date: SQLAlchemy>=0.8.0 in ./venv/lib/python2.7/site-packages (from flask-sqlalchemy)
Requirement already up-to-date: Flask>=0.10 in ./venv/lib/python2.7/site-packages (from flask-sqlalchemy)
Requirement already up-to-date: itsdangerous>=0.21 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: Jinja2>=2.4 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: Werkzeug>=0.7 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: click>=2.0 in ./venv/lib/python2.7/site-packages (from Flask>=0.10->flask-sqlalchemy)
Requirement already up-to-date: MarkupSafe>=0.23 in ./venv/lib/python2.7/site-packages (from Jinja2>=2.4->Flask>=0.10->flask-sqlalchemy)
I am trying to install use sqlalchemy inside a virtualenv. I also have python=2.7.14, pip=9.0.1, setuptools=38.2.5 and the supposed installed sqlalchemy=1.2.0. I used supposed because when I try upgrading and checking the version of sqlalchemy and flask-sqlalchemy, my computer shows that it's installed but I can't use it.
Here's what I get when I print out sys.path
['', '/usr/lib/python2.7',
'/usr/lib/python2.7/plat-x86_64-linux-gnu',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/home/j/.local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/dist-packages',
'/usr/local/lib/python2.7/dist-packages/MySQL_python-1.2.5-py2.7-linux-x86_64.egg',
'/usr/local/lib/python2.7/dist-packages/SQLAlchemy-1.2.0-py2.7-linux-x86_64.egg',
'/usr/lib/python2.7/dist-packages']
Please help me. I don't know what else to do
You're pip install is wrong.
Change sqalchemy to sqlalchemy so it is:
pip install sqlalchemy
And make sure to do so within the activated virtualenv.
I get the same error as you.
I solved it with:
I remove my virtrualenv, and create a new one
run pip3 install -r requirment.text install of sudo pip3 install -r requirment.text (if above command get permission denied error, you should run sudo chown -R user /usr/local/lib/python3.6/)
Traceback (most recent call last):
File "project.py", line 2, in <module>
import sklearn
File "/usr/local/lib/python3.6/site-packages/sklearn/__init__.py", line 134, in <module>
from .base import clone
File "/usr/local/lib/python3.6/site-packages/sklearn/base.py", line 11, in <module>
from scipy import sparse
ModuleNotFoundError: No module named 'scipy'
I've installed the sklearn package, but whenever I try to run the script with import sklearn I keep getting these errors.
The terminal is telling me it is installed.
Requirement already satisfied: sklearn in /usr/local/lib/python3.6/site-packages
Requirement already satisfied: scikit-learn in /usr/local/lib/python3.6/site-packages (from sklearn)
You're just missing another requirement which is scipy. You just need to run pip3 install scipy.
As noted by #sascha you may want to follow the system install instructions recommended by the scipy project.
I am struggling to import Librosa library for sound analyses. When I enter
import librosa
I get the following error
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "c:\python35\lib\site-packages\librosa\__init__.py", line 13, in <module>
from . import decompose
File "c:\python35\lib\site-packages\librosa\decompose.py", line 19, in <module>
import sklearn.decomposition
File "c:\python35\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "c:\python35\lib\site-packages\sklearn\base.py", line 12, in <module>
from .utils.fixes import signature
File "c:\python35\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "c:\python35\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
from ..utils.fixes import signature
File "c:\python35\lib\site-packages\sklearn\utils\fixes.py", line 406, in <module>
if np_version < (1, 12, 0):
TypeError: unorderable types: str() < int()
I am trying to do everything on Windows OS, Python 3.5 64-bit. Do I need to install some other libraries? I already installed a bunch of other libraries like numpy, matplotlib, scipy and few other essential ones. Please explain what's going on :(
Try using: pip install librosa
You should get a bunch of messages like:
Collecting librosa
Downloading librosa-0.5.1.tar.gz (1.5MB)
100% |████████████████████████████████| 1.5MB 312kB/s
Collecting audioread>=2.0.0 (from librosa)
Downloading audioread-2.1.5.tar.gz
Requirement already satisfied: numpy>=1.8.0 in c:\users\j\miniconda3\lib\site-packages (from librosa)
Requirement already satisfied: scipy>=0.13.0 in c:\users\j\miniconda3\lib\site-packages (from librosa)
Requirement already satisfied: scikit-learn>=0.14.0 in c:\users\j\miniconda3\lib\site-packages (from librosa)
Collecting joblib>=0.7.0 (from librosa)
Downloading joblib-0.11-py2.py3-none-any.whl (176kB)
etc. etc. etc.
And then librosa among other libs is installed.
PS. looks like we are working on the same project??