pip was working with me and all it's modules but after i was testing new methods in my code pychram stopped and lagged, so i restarted my laptop and now pip isn't working nor it's modules , like tweepy
This is what the computer tell me when i write pip in the cmd
File "c:\users\goldenworld\appdata\local\programs\python\python36\lib\runpy.py", line 14, in <mo dule>
import importlib.machinery # importlib first so we can test #15386 via -m
File "c:\users\goldenworld\appdata\local\programs\python\python36\lib\importlib\__init__.py", li ne 57, in <module>
import types
File "c:\users\goldenworld\appdata\local\programs\python\python36\lib\types.py", line 171, in <m odule>
import functools as _functools
File "c:\users\goldenworld\appdata\local\programs\python\python36\lib\functools.py", line 21, in <module>
from collections import namedtuple
File "c:\users\goldenworld\appdata\local\programs\python\python36\lib\collections\__init__.py", line 135
'od.__iter__() <==> iter(od)
^
SyntaxError: EOL while scanning string literal
I was using the method __iter__(),
even tkinter package isn't working.
What you have done there is totally messed the program and specifically python, I have not used pip but considering what you have done try this:
Re-Install the program.
Re-Install python.
Never attempt that again.
Related
Traceback (most recent call last):
File "g:\mydrive\ \pdftotext_pdfminer.py", line 3, in <module>
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\pdfinterp.py", line 7, in <module>
from .cmapdb import CMap
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\encodingdb.py", line 7, in <module>
from .psparser import PSLiteral
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\psparser.py", line 22, in <module>
from .utils import choplist
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\pdfminer\utils.py", line 31, in <module>
import charset_normalizer # For str encoding detection
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\__init__.py", line 23, in <module>
from charset_normalizer.api import from_fp, from_path, from_bytes, normalize
File "C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\api.py", line 10, in <module>
from charset_normalizer.md import mess_ratio
File "charset_normalizer\md.py", line 5, in <module>
ImportError: cannot import name 'COMMON_SAFE_ASCII_CHARACTERS' from 'charset_normalizer.constant' (C:\Users\ \anaconda3\envs\ \lib\site-packages\charset_normalizer\constant.py)
This error happens whenever I'm using pdfminer. I also installed pdfminer-six
My code worked just fine until two days ago.
It started to happen today when I tried to just run it again without any adjustment in the file
I'm assuming maybe it's the pdfminer's problem but there's no update about the module...
(I'm running this on my conda env)
Does anyone know what this error means? and how to fix it?
When I encountered this I used:
pip install chardet
there. I faced the same problem when trying to use the pdfplumber package today (2022-11-24) from a script I have long used with no problem. I don't know why this error is happening but found one of the solutions in this link helpful:
How to fix AttributeError: partially initialized module?
Briefly, I removed my entire virtual environment using the command conda env remove --name ds (being ds the name of my environment). Then, I created a new one and installed every package I needed again through conda or pip. It is working perfectly now. Hope it works for you as well.
Out of curiosity, I have installed Tensorflow last week. Maybe it interfered with pdfplumber somehow (not sure). Have you installed any new package since the last time you used pdfminer? Best of luck!
use follow instead.
pip install mmcv-full==1.3.17
I had this project running on my Mac here under python3. It took a while after doing a 2to3 to update some other bits and pieces to it to finally get it to run. Now though the project fails and all I recall of doing to my mac is:
Upgrading the OS
Upgrading Xcode and other pieces so that a 'brew install root' would work.
Not sure what else it touched but it is like it lost all the modules I had done a pip install on. So i redid a pip install on several modules
astropy
matplotlib
scipy
now the project fails when I run it:
File "/Users/shathoma/TUI3/TUI/Guide/GuideImage.py", line 26, in <module>
import astropy.io.fits as pyfits
File "/usr/local/lib/python3.9/site-packages/astropy/io/fits/__init__.py", line 70, in <module>
from . import convenience
File "/usr/local/lib/python3.9/site-packages/astropy/io/fits/convenience.py", line 63, in <module>
from .diff import FITSDiff, HDUDiff
File "/usr/local/lib/python3.9/site-packages/astropy/io/fits/diff.py", line 25, in <module>
from .header import Header
File "/usr/local/lib/python3.9/site-packages/astropy/io/fits/header.py", line 11, in <module>
from .file import _File
File "/usr/local/lib/python3.9/site-packages/astropy/io/fits/file.py", line 29, in <module>
from astropy.utils.compat.optional_deps import HAS_BZ2
File "/usr/local/lib/python3.9/site-packages/astropy/utils/compat/__init__.py", line 19, in <module>
from .numpycompat import * # noqa
File "/usr/local/lib/python3.9/site-packages/astropy/utils/compat/numpycompat.py", line 14, in <module>
NUMPY_LT_1_19 = not minversion('numpy', '1.19')
File "/usr/local/lib/python3.9/site-packages/astropy/utils/decorators.py", line 546, in wrapper
return function(*args, **kwargs)
File "/usr/local/lib/python3.9/site-packages/astropy/utils/introspection.py", line 167, in minversion
return Version(module_version) >= Version(version)
File "/usr/local/lib/python3.9/site-packages/packaging/version.py", line 264, in __init__
match = self._regex.search(version)
TypeError: expected string or bytes-like object
I have this project running fine still under a windows machine and the versions of the installed modules like astropy etc are the same. Still fails on the mac with the above error. I could go in and fix packaging/version.py to deal with a self._regex.search(str(version)) which is a bad Idea I know (I tried that and since reverted it gave an error on how version = none somewhere.
it is almost like I am missing a module but nothing knows it? Not sure, and not sure how after working this broke with just probably the brew install command of the root (https://root.cern.ch/) package. Out of ideas what to look for or try next to get this running again?
Running a locust (locust.io) script from the command line.
locust calls main.py which has the following imports:
from locust import HttpUser, between, task
from StreamLoader.stream_generator import * # thought this brings in everything
Packer.py has these imports:
from multipledispatch import dispatch
from PackedItem import PackedItem
StreamGenerator.py has:
import hashlib
from StreamLoader.Packer import Packer
from aes_encryption import AesEncryption
I used pip to install multipledispatch and when I run from within PyCharm it works fine, but from the command line I get the following.
File "C:\Users\guyl\PycharmProjects\engine-load-tests\engine_load_tester_locust\main.py", line 2, in <module>
from StreamLoader.stream_generator import *
File "C:\Users\guyl\PycharmProjects\engine-load-tests\StreamLoader\stream_generator.py", line 2, in <module>
from StreamLoader.Packer import Packer
File "C:\Users\guyl\PycharmProjects\engine-load-tests\StreamLoader\Packer.py", line 1, in <module>
from multipledispatch import dispatch
ModuleNotFoundError: No module named 'multipledispatch'
Here is what I have tried so far:
Add directories to the PYTHONPATH environment variable
Add empty __init__.py files in each package
This all seems unnecessary if I actually pip installed the module, though.
Answer below caused me to no longer see the error with multipledispatch. However, I now see a missing module error:
File "C:\Users\guyl\PycharmProjects\engine-load-tests\engine_load_tester_locust\main.py", line 2, in <module>
from StreamLoader.stream_generator import *
File "C:\Users\guyl\PycharmProjects\engine-load-tests\StreamLoader\stream_generator.py", line 2, in <module>
from Packer import Packer
ModuleNotFoundError: No module named 'Packer'
For clarity, I am running the code from locust which calls the Python code as depicted here. [Moderators - this question is getting quite long. Is that all right?]
PyCharm uses the virtual environment automatically but when you run from the command line the virtual environment isn't turned on.
Just follow the steps:
cd your_working_directory
environment_name/Scripts/activate if on Windows where environment_name is the name of the PyCharm virtual environment
Or environment_name/bin/activate if on MacOS
-------------EDIT------------------------
To answer the new question, try using pip freeze then see which packages are installed. Then install any dependencies which you want which are missing.
I have a cloud instance of a Linux machine (openSuSE) with multiple users.
I have created a virtual environment and installed all my required libraries (including Klein).
I have two users "a" and "b".
While logged in as "a" and inside virtualenv, when I open python shell at home directory and type
import klein
it imports normally.
Now when I change directory to
/home/b/
and run the same (open python shell, import klein) while being in the same virtualenv, it gives me an error.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/a/.local/lib/python3.6/site-packages/klein/__init__.py", line 3, in <module>
from klein._plating import Plating
File "/home/a/.local/lib/python3.6/site-packages/klein/_plating.py", line 16, in <module>
from .app import _call
File "/home/a/.local/lib/python3.6/site-packages/klein/app.py", line 19, in <module>
from twisted.internet import endpoints, reactor
File "/home/a/.local/lib/python3.6/site-packages/twisted/internet/endpoints.py", line 58, in <module>
from twisted.protocols.tls import TLSMemoryBIOFactory
File "/home/a/.local/lib/python3.6/site-packages/twisted/protocols/tls.py", line 63, in <module>
from twisted.internet._sslverify import _setAcceptableProtocols
File "/home/a/.local/lib/python3.6/site-packages/twisted/internet/_sslverify.py", line 158, in <module>
verifyHostname, VerificationError = _selectVerifyImplementation()
File "/home/a/.local/lib/python3.6/site-packages/twisted/internet/_sslverify.py", line 141, in _selectVerifyImplementation
from service_identity import VerificationError
File "/home/a/.conda/envs/mm/lib/python3.6/site-packages/service_identity/__init__.py", line 7, in <module>
from . import cryptography, pyopenssl
File "/home/a/.conda/envs/mm/lib/python3.6/site-packages/service_identity/cryptography.py", line 16, in <module>
from .exceptions import SubjectAltNameWarning
File "/home/a/.conda/envs/mm/lib/python3.6/site-packages/service_identity/exceptions.py", line 21, in <module>
#attr.s
AttributeError: module 'attr' has no attribute 's'
Command "which python" gives same address at both location which is my virtualenv python address and that should be expected.
But what causes this weird python shell behavior.
Thank you
I solved it and a very shameful reason caused the error.
One of the modules Twisted uses is "attr" module. I had named one of my files attr.py and that is what was causing all the error.
I myself am not deleting this question if moderation has no problem, maybe somebody like me might be stuck at the same situation. It may help them.
Never name your python files same as that of any standard module unless overriding.
Also if your issue persists, then Jean's answer will definitely resolve it.
There can be multiple different Python packages that provide the same Python module. For example, there are at least two packages that provide the attr module:
https://pypi.org/project/attr/
https://pypi.org/project/attrs/
It's possible you've installed the wrong package based on the requirements. You can check what you have installed with pip freeze.
I am working in Ubuntu 14.04 and I have multiple versions of Python on my machine (they include python2.7 and python3.4). Few days back, I installed simplejson on my system. I don't remember how I did that but I guess it must be similar to pip install simplejson. However, now a strange problem has started appearing when I try installing any python package. For example, just now I tried installing Tkinter using sudo pip3.4 install Tkinter and it throws the following error:
Traceback (most recent call last):
File "/usr/local/bin/pip3.4", line 9, in <module>
load_entry_point('pip==1.5.4', 'console_scripts', 'pip3.4')()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 351, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2363, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources.py", line 2088, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 61, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python3/dist-packages/pip/vcs/subversion.py", line 4, in <module>
from pip.index import Link
File "/usr/lib/python3/dist-packages/pip/index.py", line 15, in <module>
from pip.wheel import Wheel, wheel_ext
File "/usr/lib/python3/dist-packages/pip/wheel.py", line 25, in <module>
from distlib.scripts import ScriptMaker
File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/scripts.py", line 15, in <module>
File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/resources.py", line 20, in <module>
File "/usr/share/python-wheels/distlib-0.1.8-py2.py3-none-any.whl/distlib/util.py", line 11, in <module>
ImportError: No module named 'json'
Sometimes I can fix this if the error tells me that in one of the files I have:
import json
which I simply convert to
import simplejson as json
I tried uninstalling simplejson:
sudo pip uninstall simplejson
but it gives me the same error: json not found.
Can anybody please help me fix this so that I would happily be able to install python packages? Thanks in advance.
Note: I do not have a definitive answer but will offer a series of steps you can try:
The first thing is see if you can import json from the usual python interpreter:
import json
print(json.__file__) #this would be important to know if it works
If that does work (as well as commenting what json.__file__ is) you would then want to try to use pip from the interpreter.
If you can't import json normally:
This is not surprising, I did not expect pip to be looking in a non-standard place for modules. You will want to figure out where the json package should be located on your computer, you can do this by importing another module from the standard library and looking at it's __file__:
>>> import fractions
>>> fractions.__file__
'/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/fractions.py'
This will obviously be different for you but I'd expect there to be a json folder in the same folder as fractions.py
if you can't import fractions or queue or datetime etc.
If you can't import anything from the standard library you will probably want to just reinstall python.
If the json folder is there and contains an __init__.py
Use the rename function of your file browser to make sure there are no weird special characters, but other then that I'm not sure, if you can import fractions.py but not a package from the same folder that would imply there is something very wrong with the import mechanics of your python version.
If the json folder is not with the rest of the standard library
It is possible that your python distribution has a different structure then I'd expect, it at least can't hurt to take a look for it.
You can search for the json folder amongst your various python files using the find command, not really sure how it works but just another thing to try. If you do find it with the __init__.py, encode.py, decode.py, scanner.py, and tool.py (at least those are the ones in my version) you'll probably want to figure out how it got there, but maybe just move it to the same folder as the rest of the standard library.
If you can't find the json package or you find it and it is corrupted
Well then you will need to replace it! Don't worry, this isn't too hard, just grab a source release of python from the site and extract the json package from it, once it is uncompressed the json folder should be in the Lib folder. Simply copy/move it to the rest of the standard library and you should be good to go!
I hope this helps you debug what is going on, This covers all the scenarios I could imagine happening and I would be interested in which one fixed your issue (or what you were able to figure out so I can come up with more options)
I am guessing that you install it using either pip install simplejson to download from PyPI or using apt-get install python-simplejson to download from ubuntu repositories.
It is possible that you downlaoded the library for the Python2 if you used any of the commands above and it won't be available for Python3 (which pip3.4 will use). Can you try these commands and help debug yourself?
$ python -c "import simplejson"
$ python3.4 -c "import simplejson"
This would tell you which version of the python did you install simplejson for last time (my guess in python2). If the 2nd command errors out with ImportError try:
$ pip3.4 install simplejson
and then install your libraries.