Piggybacking off a previous question that I submitted: Using WordNet with PyScript
I'm trying to install WordNet in PyScript using
await micropip.install('https://files.pythonhosted.org/packages/ce/f1/53b07100f5c3d41fd33fc78ebb9e99d736b0460ced8acff94840311ffc60/wn-0.9.1-py3-none-any.whl')
This gives me the error:
JsException(PythonError: Traceback (most recent call last):
File "/lib/python3.10/asyncio/futures.py", line 201, in result raise self._exception
File "/lib/python3.10/asyncio/tasks.py", line 232, in __step result = coro.send(None)
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 500, in eval_code_async await CodeRunner(
File "/lib/python3.10/site-packages/_pyodide/_base.py", line 353, in run_async await coroutine File "", line 14, in
File "/lib/python3.10/site-packages/wn/init.py", line 47, in from wn._add import add, remove File "/lib/python3.10/site-packages/wn/_add.py", line 21, in from wn.project import iterpackages
File "/lib/python3.10/site-packages/wn/project.py", line 12, in import lzma
File "/lib/python3.10/lzma.py", line 27, in from _lzma import * ModuleNotFoundError: No module named '_lzma' )
Looking at some questions related to the "ModuleNotFoundError: No module named '_lzma'", the idea generally seems to be that it is an issue related to the Python installation. However, I am not sure how to go about resolving this within PyScript.
Any clues on what I did wrong/what I should do?
lzma is currently not included in Pyodide Python builds to reduce download size. Lzma remains an optional module, so the package should not fail if it's missing. You can report this issue to https://github.com/goodmami/wn
Meanwhile a temporary workaround is to remove that lzma import in wn, create a new python wheel with,
pip install build
python -m build
and install that with micropip by providing the URL.
It's possible that we may add lzma module in Pyodide the future pyodide#2937
Related
Hello I am using mac actually when I searched analytics in finder I removed some folders (I thought they are useless :) after that when I type conda update or such I am getting those errors and further more.
I am keeping exact error:
Traceback (most recent call last):
File "/Users/nunemunthalashiva/anaconda3/bin/conda", line 13, in <module>
sys.exit(main())
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/cli/main.py", line 151, in main
from ..exceptions import conda_exception_handler
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/exceptions.py", line 25, in <module>
from .common.io import dashlist, timeout
File "/Users/nunemunthalashiva/anaconda3/lib/python3.8/site-packages/conda/common/io.py", line 33, in <module>
from .._vendor.tqdm import tqdm
ImportError: cannot import name 'tqdm' from 'conda._vendor.tqdm' (unknown location)
Python comes with some libraries that are required to preform some basic operation later in python such as update or install libraries. I think you removed those python libraries that are required to update/used in other ....to remove these error you have to add/restore those libraries or reinstall python.
I am trying for a longer time.Please do help.
I installed scrapy using conda.
I tested pip show scrapy in the command line and it is working perfectly.
While i type import scrapy in the python terminal it is not showing any error.
But if i create a project or execute an existing project of scrapy i get the following error:
C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\commands\deploy.py:16: ScrapyDeprecationWarning: Module `scrapy.command` is deprecated, use `scrapy.commands` instead
from scrapy.command import ScrapyCommand
Traceback (most recent call last):
File "C:\Users\Nikeshh\Anaconda2\Scripts\scrapy-script.py", line 10, in <module>
sys.exit(execute())
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\cmdline.py", line 149, in execute
cmd.crawler_process = CrawlerProcess(settings)
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\crawler.py", line 252, in __init__
log_scrapy_info(self.settings)
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\log.py", line 149, in log_scrapy_info
for name, version in scrapy_components_versions()
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\versions.py", line 35, in scrapy_components_versions
("pyOpenSSL", _get_openssl_version()),
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\scrapy\utils\versions.py", line 43, in _get_openssl_version
import OpenSSL
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\crypto.py", line 16, in <module>
from OpenSSL._util import (
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\OpenSSL\_util.py", line 6, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "C:\Users\Nikeshh\Anaconda2\lib\site-packages\cryptography\hazmat\bindings\openssl\binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
ImportError: DLL load failed: The operating system cannot run %1.
I am using scrapy startproject tutorial to create a project.How to solve this error?
Is there any specific way to execute the scrapy code?
Even when i add openssl using conda i am getting the same error
It looks like you need the OpenSSL libraries that are used for encryption.
You could go and download these from somewhere here: https://wiki.openssl.org/index.php/Binaries
Alternatively I think the installer for git will install OpenSSL by default, which you can get here: https://git-scm.com/download
However, since you're using Anaconda, OpenSSL should also be available with conda: https://anaconda.org/anaconda/openssl
Hope this helps!
I am trying to use this sample code from the Google Natural Language API to get a sentiment score back. However, each time I run the code, I get an "ImportError: cannot import name language." error on the first line.
I have pip installed the library, tried uninstalling and reinstalling, made the credentials on the console (the API is shown to be enabled) and looked at this tutorial too and completed those steps in the answer: Google sentiment analysis - ImportError: cannot import name language. It hasn't helped. Is there anything else I can try?
from google.cloud import language
from google.cloud.language import enums
from google.cloud.language import types
client = language.LanguageServiceClient()
text = u'Hello, world!'
document = types.Document(
content=text,
type=enums.Document.Type.PLAIN_TEXT)
sentiment = client.analyze_sentiment(document=document).document_sentiment
print('Text: {}'.format(text))
print('Sentiment: {}, {}'.format(sentiment.score, sentiment.magnitude))
I also have pasted this into my terminal with the proper path.
export GOOGLE_APPLICATION_CREDENTIALS="/....(my path)/service_key.json"
Stack trace:
Traceback (most recent call last):
File "lang.py", line 3, in <module>
from google.cloud import language
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/cloud/language.py", line 17, in <module>
from google.cloud.language_v1 import LanguageServiceClient
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/cloud/language_v1/__init__.py", line 17, in <module>
from google.cloud.language_v1 import types
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/cloud/language_v1/types.py", line 18, in <module>
from google.api_core.protobuf_helpers import get_messages
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/google/api_core/__init__.py", line 20, in <module>
from pkg_resources import get_distribution
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3161, in <module>
#_call_aside
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3145, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3189, in _initialize_master_working_set
for dist in working_set
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3189, in <genexpr>
for dist in working_set
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2715, in activate
declare_namespace(pkg)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2274, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2209, in _handle_ns
loader.load_module(packageName)
File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/pkgutil.py", line 246, in load_module
mod = imp.load_module(fullname, self.file, self.filename, self.etc)
File "/.../lang.py", line 3, in <module>
from google.cloud import language
ImportError: cannot import name language
This seems to be a duplicate of this question:
Google sentiment analysis - ImportError: cannot import name language
For me, wasn't enough to upgrade google-api-python-client and google-cloud
Instead, what solved my problem was:
!pip install google-cloud-language
Besides, when you upgrade google api libraries, an incompatibility error shows up with awsebcli library (from AWS).
The explanation:
If you look at the stack trace, the import of google.cloud.language is actually working and it is not circular. The second and third items in the stack trace are langauge.py successfully asking for the items underneath, ultimately delegating off to google.api_core (which is our runtime behind all of these libraries).
The fifth line in the trace is the interesting one: it corresponds to line 20 of google/api_core/__init__.py and it is from pkg_resources import get_distribution. Everything that comes after that is an attempt to make that import work; since it does not, the ImportError bubbles up, and the previous imports cascade-fail.
Probable solution:
Make sure your pip and setuptools are up to date. Namespace packing is notoriously tricky so you have to have a pretty recent version. Just issue pip install --upgrade setuptools pip.
Gordian solution:
Have you considered Python 3? :-)
Troubleshooting:
If that does not work (and Python 3 is not an option), the next thing we need to know is what that final failure is. The penultimate call in the track is a call to imp.load_module(fullname, self.file, self.filename, self.etc). We will need to know what those values are to troubleshoot further. To get them, add import pdb ; pdb.set_trace() immediately before the import in your code that is failing. This will toss you into a debugger at that point. Use n (next) and s (step into function) to move through the code (you can get variable values and such by typing them in the REPL). If you can print the values of what is trying to be imported specifically, we can assist you further.
Try to upgrade pip:
python -m pip install --upgrade pip
Then upgrade the Google packages:
pip install --upgrade google-api-python-client
pip install --upgrade google-cloud
If using Google Cloud Functions, make sure google-cloud-language is specified in the requirements.txt tab:
The following solved my issue:
pip install google-cloud-translate
Then i ran the following code smoothly:
from google.cloud import translate
reference: https://pypi.org/project/google-cloud-translate/
I'm working on a project to play around with a csv file, however, I can't get pandas to work. Everything I have researched so far has just told me to make sure that pandas is installed. Using pip I have managed to install pandas just fine. When I try to run my python program and import pandas I get:
Traceback (most recent call last):
File "analysis.py", line 1, in <module>
import pandas as pd
ImportError: No module named pandas
I don't know if this is related, but I was trying to see see if this would work with conda install pandas however, I get this import error:
(Again, Anaconda is correctly installed on my system)
Traceback (most recent call last):
File "/usr/local/bin/conda", line 9, in <module>
load_entry_point('conda==4.2.7', 'console_scripts', 'conda')()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2627, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2287, in load
return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2293, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Library/Python/2.7/site-packages/conda/cli/__init__.py", line 8, in <module>
from .main import main # NOQA
File "/Library/Python/2.7/site-packages/conda/cli/main.py", line 46, in <module>
from ..base.context import context
File "/Library/Python/2.7/site-packages/conda/base/context.py", line 18, in <module>
from ..common.configuration import (Configuration, MapParameter, PrimitiveParameter,
File "/Library/Python/2.7/site-packages/conda/common/configuration.py", line 40, in <module>
from ruamel.yaml.comments import CommentedSeq, CommentedMap # pragma: no cover
ImportError: No module named ruamel.yaml.comments
Anyone have a similar experience importing libraries? I have tried to make sure that I have the correct versions for Python3 but that doesn't seem to be the issue. Any help would be greatly appreciated! Thank you.
The problem is that the 'lib' folder that pip installs things into has a separate subdirectory for each python environment that you're working with (by default this is python2.7). A simple workaround is to build a virtual environment of python3 and then installing pandas or whatever package you want into it. To achieve this, try the following:
virtualenv -p /usr/bin/python3 python3
Now, each time you want to pip install a python3 package, run
source python3/bin/activate
pip install pandas --user
Hope this helps
Go to powershell on your system and pip install pandas. you will see a successfully installed command. you can install other modules too like matplotlib et al.
After I installed PyReadline, IPython won't work. When I uninstalled it, it starts working again.
The stack trace for ipython:
(py2.7_monitor)[root#vm10-136-8-98 monitor]# ipython
WARNING: IPython History requires SQLite, your history will not be saved
Traceback (most recent call last):
File "/home/py2.7_monitor/bin/ipython", line 11, in <module>
sys.exit(start_ipython())
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/__init__.py", line 118, in start_ipython
return launch_new_instance(argv=argv, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/application.py", line 591, in launch_instance
app.initialize(argv)
File "<string>", line 2, in initialize
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/application.py", line 75, in catch_config_error
return method(app, *args, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 314, in initialize
self.init_shell()
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/terminal/ipapp.py", line 330, in init_shell
ipython_dir=self.ipython_dir, user_ns=self.user_ns)
File "/home/py2.7_monitor/lib/python2.7/site-packages/traitlets/config/configurable.py", line 380, in instance
inst = cls(*args, **kwargs)
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 531, in __init__
self.init_readline()
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 1941, in init_readline
import IPython.utils.rlineimpl as readline
File "/home/py2.7_monitor/lib/python2.7/site-packages/IPython/utils/rlineimpl.py", line 21, in <module>
_rl = __import__(_rlmod_name)
File "/home/py2.7_monitor/lib/python2.7/site-packages/readline.py", line 6, in <module>
from pyreadline.rlmain import Readline
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/__init__.py", line 12, in <module>
from . import logger, clipboard, lineeditor, modes, console
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/clipboard/__init__.py", line 13, in <module>
from .win32_clipboard import GetClipboardText, SetClipboardText
File "/home/py2.7_monitor/lib/python2.7/site-packages/pyreadline/clipboard/win32_clipboard.py", line 37, in <module>
import ctypes.wintypes as wintypes
File "/usr/local/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported
As stated on their site, the PyReadline library is Used for Windows.
Looking at the last lines of your stack trace:
import ctypes.wintypes as wintypes
File "/usr/local/lib/python2.7/ctypes/wintypes.py", line 23, in <module>
class VARIANT_BOOL(_SimpleCData):
ValueError: _type_ 'v' not supported
It is trying to import windows specific data types from ctypes which is obviously not possible since you are not running Windows.
This will likely help exactly no one in the year 2020 or beyond, but all the same I want to record it here for posterity.
I experienced the same ValueError: _type_ 'v' not supported traceback with an installation of Python 2.7.16 in an HPC cluster environment, attempting to install pdbpp, which depends on fancycompleter, which depends on pyreadline, which imports ctypes.wintypes and is affected by this this core Python issue from 2012.
It's true that ctypes.wintypes should never be imported on a non-Windows platform (Cygwin, MSYS2, and Git Bash are technically non-Windows, since they will have a real GNU Readline library and don't need the pure Python shim).
However if it were imported on a non-Windows platform, because of the issue mentioned above, ctypes.wintypes throws a ValueError instead of an ImportError, which means that a typical try/except that expects to catch an ImportError will just blow up because of the unhandled exception.
Pdbpp's fancycompleter, or rather pyreadline, somehow fell victim to this. I get confused about who's to blame, because fancycompleter's setup.py isn't supposed to bring in pyreadline as a dependency except on Windows, but somehow there it was on my Linux system. And if it's there, fancycompleter tries to import it.
All I can figure is I may have had an old fancycompleter in my pip cache with a typo in its setup.py that was pulling in pyreadline when it shouldn't have, because it was grabbing that dependency, time after time.
What actually finally resolved this situation for me was to pip uninstall pyreadline, then pip install -U --ignore-installed --no-cache-dir fancycompleter to get a "fresh" version of fancycompleter that did not bring in the unnecessary pyreadline dependency.