i just installed pytest and i tried using it and it was giving me errors. i uninstalled it and installed it again and it was giving me the same errors as i tried importing it
import pytest
Traceback (most recent call last):
File "C:/Users/user/AppData/Roaming/JetBrains/PyCharmCE2021.1/scratches/scratch_1.py", line 1, in <module>
import pytest
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\pytest\__init__.py", line 7, in <module>
from _pytest.assertion import register_assert_rewrite
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\_pytest\assertion\__init__.py", line 10, in <module>
from _pytest.assertion import rewrite
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\_pytest\assertion\rewrite.py", line 26, in <module>
import py
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py\__init__.py", line 14, in <module>
from py._vendored_packages import apipkg
File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\py\_vendored_packages\apipkg\__init__.py", line 12, in <module>
from .version import version as __version__
ValueError: source code string cannot contain null bytes
can you please help me with what to do, or suggest another library just like pytest where i test my applications.
Thanks for your contribution
check if you installed pytest in the same pyenv you are using. Run pip list comand and check there is pytest there
It might be issue with environment in pyenv. Try to create new one. In PyCharm it is File -> Settings -> Project -> Python Interpreter -> Add
Related
I am using Jython version 2.7.2 and I installed it using brew. And, I am using Python version 3.9.9. I want to use my python module in Jython. For doing the same, when I try
jython ez_setup.py , I get the following error :
Traceback (most recent call last):
File "ez_setup.py", line 278, in <module>
main(sys.argv[1:])
File "ez_setup.py", line 212, in main
from setuptools.command.easy_install import main
File "/Users/prachikhattar/Desktop/setuptools-0.6c11-py2.7.egg/setuptools/__init__.py", line 2, in <module>
File "/Users/prachikhattar/Desktop/setuptools-0.6c11-py2.7.egg/setuptools/extension.py", line 2, in <module>
File "/Users/prachikhattar/Desktop/setuptools-0.6c11-py2.7.egg/setuptools/dist.py", line 5, in <module>
File "/opt/homebrew/Cellar/jython/2.7.2/libexec/Lib/_fix_jython_setuptools_osx.py", line 10, in <module>
from setuptools.command import easy_install as ez
File "/Users/prachikhattar/Desktop/setuptools-0.6c11-py2.7.egg/setuptools/command/easy_install.py", line 14, in <module>
ImportError: cannot import name Command
Can anyone please tell me what's going wrong?
Any help would be highly appreciated.
Thank you
I have been trying to implement pandas profiling in aws glue. One of the dependencies it uses is pillow. Since these are not there in aws glue by default I packaged them into a zip file and uploaded it.
After that I ran the line
from pandas_profiling import ProfileReport
which gives the error ImportError: cannot import name '_imaging' from 'PIL'
The complete stack trace is:
File "/tmp/pandastest2", line 1, in <module>
from pandas_profiling import ProfileReport
File "/tmp/hope.zip/pandas_profiling/__init__.py", line 6, in <module>
from pandas_profiling.controller import pandas_decorator
File "/tmp/hope.zip/pandas_profiling/controller/pandas_decorator.py", line 4, in <module>
from pandas_profiling.profile_report import ProfileReport
File "/tmp/hope.zip/pandas_profiling/profile_report.py", line 15, in <module>
from pandas_profiling.model.describe import describe as describe_df
File "/tmp/hope.zip/pandas_profiling/model/describe.py", line 14, in <module>
from pandas_profiling.model.summarizer import BaseSummarizer
File "/tmp/hope.zip/pandas_profiling/model/summarizer.py", line 9, in <module>
from pandas_profiling.model.summary_algorithms import (
File "/tmp/hope.zip/pandas_profiling/model/summary_algorithms.py", line 11, in <module>
from pandas_profiling.model.summary_helpers import (
File "/tmp/hope.zip/pandas_profiling/model/summary_helpers.py", line 15, in <module>
from pandas_profiling.model.summary_helpers_image import (
File "/tmp/hope.zip/pandas_profiling/model/summary_helpers_image.py", line 5, in <module>
import imagehash
File "/tmp/hope.zip/imagehash.py", line 34, in <module>
from PIL import Image, ImageFilter
File "/tmp/hope.zip/PIL/Image.py", line 114, in <module>
from . import _imaging as core
ImportError: cannot import name '_imaging' from 'PIL'
So the specific problem is with the line from PIL import Image
I tried from PIL import ImageFilter and import PIL and both run without any error. So the only issue here is with the Image module.
This does not happen when I run it locally in my system. Is there someway to fix this issue and make it work in aws glue?
When packaging the dependencies I made sure that the python version on my local system and aws glue were the same version namely python 3.7. I used Pillow version 8.2.3 and pip was the latest version.
I want to import ee.mapclient
but when I do this the following error is returned:
Traceback (most recent call last):
File "<ipython-input-16-5f312fd5c732>", line 1, in <module>
import ee.mapclient
File "C:\Users\Stefano\Anaconda2_2\lib\site-packages\ee\mapclient.py", line 43, in <module>
import ImageTk # pylint: disable=g-import-not-at-top
ImportError: No module named ImageTk
I am using anaconda and have installed pillow and PIL. Within my PIL folder in site-packages there is a file caled ImageTk.
When I do this:
from PIL import Image, ImageTk
everything imports fine, but for some reason ee.mapclient is not recognizing this.
A link to the python code used in mapclient.py can be found here:
https://github.com/google/earthengine-api/blob/master/python/ee/mapclient.py
Edit mapclient to put "from PIL import Image,ImageTk " in try block ,
I am attempting to use the template library Django on eclipse. SO far I downloaded the Django-1.7.tar.gz and unzipped it. Then from eclipse I placed it as an external library so that I could import the module. And I can import the module leave it unused and compile my code no problem. However when I call template() I have issues.
Code:
import numpy as np
from django.template import Template, Context
t=Template("My name is {{my_name}}.")
c=Context({"my_name":"Adrian"})
t.render(c)
Output error
Traceback (most recent call last):
File "C:\Users\212412120\workspace\protype_1\main.py", line 8, in <module>
t=Template("My name is {{my_name}}.")
File "C:\Users\212412120\Downloads\Django-1.7\Django- 1.7\django\template\base.py", line 130, in __init__
if settings.TEMPLATE_DEBUG and origin is None:
File "C:\Users\212412120\Downloads\Django-1.7\Django- 1.7\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "C:\Users\212412120\Downloads\Django-1.7\Django-1.7\django\conf\__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting TEMPLATE_DEBUG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I think it has something to do with the environment variables, but I am not sure. Any ideas on how to fix this issue?
I got the answer, you have to call settings.configure() it looks like this.
import django.conf import settings
settings.configure()
I recently installed python 3.4 using this custom installation guide, the system had python 2.6 as default. Today i needed to install tldextract to python2.6
I did that using pip pip2.6 install tldextract but after i tried to import the module the import failed with this error.
Traceback (most recent call last):
File "process.py", line 12, in <module>
import tldextract
File "/usr/lib/python2.6/site-packages/tldextract/__init__.py", line 1, in <module>
from .tldextract import extract, TLDExtract
File "/usr/lib/python2.6/site-packages/tldextract/tldextract.py", line 70, in <module>
from urllib.request import urlopen
ImportError: No module named request
That seems to be the python3.4 version of tldextract since it is trying to find the request module in urllib. So i guess pip installed the wrong version of the module, how can i fix this? Or remove python 3.4 alltogether.
tldextract has the following code block in the source repo, and the line numbers match:
try: # pragma: no cover
# Python 2
from urllib2 import urlopen
from urlparse import scheme_chars
unicode = unicode
except ImportError: # pragma: no cover
# Python 3
from urllib.request import urlopen
So it looks like the Python 2 branch is throwing an exception for some unknown reason and it's failing over to Python 3. I would start by looking why that might be.