Python, pip not working, but can't install pip - python

I've cloned a project and so when trying to install the packages in the scripts, I get the following error when trying to install from pycharm:
proposed solution:
Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at '/home/yovel/PycharmProjects/Triangulation-Calculator/venv/bin/python'.
Error: Traceback (most recent call last):
File "/snap/pycharm-community/179/plugins/python-ce/helpers/packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.8/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.8/runpy.py", line 95, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/lib/python3.8/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/usr/lib/python3/dist-packages/pip/_internal/__init__.py", line 40, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 8, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 18, in <module>
from pip._internal.models.format_control import FormatControl
File "/usr/lib/python3/dist-packages/pip/_internal/models/format_control.py", line 1, in <module>
from pip._vendor.packaging.utils import canonicalize_name
ModuleNotFoundError: No module named 'pip._vendor.packaging'
But when I run it from the terminal it successfully installs the package.
pip3 install pandas
...
Successfully installed pandas-1.0.1 python-dateutil-2.8.1 pytz-2019.3
But in pycharm I can't use it:
I tried updating venv and pip but it won't work.
And I should mention that it is not the original interpreter as the original's version was python 3.6.

Related

pipenv shell on VSCode returns WSAStartup failed: error code 10107

I'm running VSCode on windows 10, driver Python 3.8.3 32bits.
When I type on terminal: pipenv shell
I get this error: ImportError: WSAStartup failed: error code 10107
Here's the complete output
Traceback (most recent call last): File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 194, in run_module_as_main
return run_code(code, main_globals, None, File "c:\users\camar\appdata\local\programs\python\python38-32\lib\runpy.py",
line 87, in run_code
exec(code, run_globals) File "C:\Users\camar\AppData\Local\Programs\Python\Python38-32\Scripts\pipenv.exe_main.py",
line 4, in File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv_init.py",
line 22, in
from pipenv.vendor.urllib3.exceptions import DependencyWarning File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3_init.py",
line 11, in
from . import exceptions File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\exceptions.py",
line 3, in
from .packages.six.moves.http_client import IncompleteRead as httplib_IncompleteRead File
"c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 199, in load_module
mod = mod._resolve() File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 113, in _resolve
return _import_module(self.mod) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\site-packages\pipenv\vendor\urllib3\packages\six.py",
line 82, in _import_module
import(name) File "c:\users\camar\appdata\local\programs\python\python38-32\lib\http\client.py",
line 71, in
import email.parser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\parser.py",
line 12, in
from email.feedparser import FeedParser, BytesFeedParser File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\feedparser.py",
line 27, in
from email._policybase import compat32 File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email_policybase.py",
line 9, in
from email.utils import _has_surrogates File "c:\users\camar\appdata\local\programs\python\python38-32\lib\email\utils.py",
line 29, in
import socket File "c:\users\camar\appdata\local\programs\python\python38-32\lib\socket.py",
line 49, in
import _socket ImportError: WSAStartup failed: error code 10107
I'd like to know how to solve this or, at least, what can I do alternatively to create a virtual enviroment.
Do you want to create a new env?
in that case you can use:
python -m venv myenv
if you want to open an existing environment in a shell you have to run "activate"
which is a file located in the myvenv/scripts folder.
Open you shell, move to the scripts dir and type activate.
You should see a new line in you shell starting with "(venv)"

I Can't understand why I'm not being able to use pycoin package in my python project, even it being installed

So, I'm trying to this this imports:
from pycoin.ecdsa import generator_secp256k1, sign, verify
But I always get this error:
Unresolved reference 'pycoin'
The thing is, pycoin is already installed in my machine so I can't understand why it isn't working...the IDE offers me the opportunity to install the package, since it doesn't recognize it, but still, I receive this error after the attempt of installation:
Error: Traceback (most recent call last):
File "/snap/pycharm-professional/218/plugins/python/helpers/packaging_tool.py", line 73, in run_pip
runpy.run_module(module_name, run_name='__main__', alter_sys=True)
File "/usr/lib/python3.6/runpy.py", line 205, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/lib/python3.6/runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/usr/lib/python3/dist-packages/pip/__main__.py", line 16, in <module>
from pip._internal.cli.main import main as _main # isort:skip # noqa
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/lib/python3/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/lib/python3/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/lib/python3/dist-packages/pip/_internal/cli/cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util
This is what I receive when I try to install pycoin again with the comand line:
➜ sudo python3 -m pip install pycoin
[sudo] password for pedro:
Requirement already satisfied: pycoin in /usr/local/lib/python3.8/dist-packages (0.90.20200809)
So it is installed, I just can't figure it out why it is not working...
When you run sudo python3 -m pip install pycoin you are seeing it installed into python3.8 but when you run it in the IDE it's attempting to install it on python3.6. So yes, it's installed, but you have multiple distributions of python.
To fix the python 3.6 issue, search ModuleNotFoundError: No module named 'distutils.util there are answers on fixing it.

Tensorflow ImportError: DLL load failed: The specified module could not be found

I've seen that a lot of questions have already asked this, but it seems to be very specific as none of the answers seem to work.
Let me explain the steps that I have taken to install everything:
I started with installing Python 3.7.4 and installed tensorflow after that. The command I ran is: pip install -q tensorflow=2.0.0-alpha0. This didn't seem to work and I soon figured out that this is because of the version of Python. Tensorflow doesn't support 3.7 yet, so I installed Python 3.6.0.
I then installed tensorflow again with the following command: pip3.6 install tensorflow. Note the explicit pip3.6. I then select python 3.6 in the configuration of Visual Code's Python Debugger. I ran the following code (single line) and gave me the following error:
Python
import tensorflow as tf
Output
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 98, in <module>
from tensorflow_core import *
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
from tensorflow.python.tools import module_util as _module_util
File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
module = self._load()
File "C:\Program Files\Python36\lib\site-packages\tensorflow\__init__.py", line 44, in _load
module = _importlib.import_module(self.__name__)
File "C:\Program Files\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\python\__init__.py", line 52, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "C:\Program Files\Python36\lib\site-packages\tensorflow_core\core\framework\graph_pb2.py", line 7, in <module>
from google.protobuf import descriptor as _descriptor
File "C:\Program Files\Python36\lib\site-packages\google\protobuf\descriptor.py", line 47, in <module>
from google.protobuf.pyext import _message
ImportError: DLL load failed: The specified module could not be found.
After some searching, someone said that uninstalling tensorflow-estimator and tensorflow-gpu may work, because of unsupported gpu's. Even though I doubted this since I have an RTX 2080, I decided to give it a go, but I still got the same result.
I'm hoping any of you would be able to help me with this.
Thanks in advance!
UPDATE
After installing Anaconda and using conda to install my packages with (instead of pip) this issue has been resolved. However, a nice issue occurs. With the someline of code I get the following error (pretty much the same as the last one, but a different package module):
Traceback (most recent call last):
File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\ptvsd_launcher.py", line 43, in <module>
main(ptvsdArgs)
File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 432, in main
run()
File "c:\Users\Meine Zeinstra\.vscode\extensions\ms-python.python-2019.9.34911\pythonFiles\lib\python\ptvsd\__main__.py", line 316, in run_file
runpy.run_path(target, run_name='__main__')
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 263, in run_path
pkg_name=pkg_name, script_name=fname)
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 96, in _run_module_code
mod_name, mod_spec, pkg_name, script_name)
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "c:\Users\Meine Zeinstra\Documents\Projects\Python_Neural_Networks\Tutorial_1\Tutorial_1.py", line 1, in <module>
import tensorflow as tf
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\tensorflow\__init__.py", line 34, in <module>
from tensorflow.python import pywrap_tensorflow # pylint: disable=unused-import
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\tensorflow\python\__init__.py", line 47, in <module>
import numpy as np
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\numpy\__init__.py", line 140, in <module>
from . import _distributor_init
File "C:\Users\Meine Zeinstra\.conda\envs\Python 3.6\lib\site-packages\numpy\_distributor_init.py", line 34, in <module>
from . import _mklinit
ImportError: DLL load failed: The specified module could not be found.
I hope you can help me with this new issue.

I'm getting ModuleNotFoundError: No module named _socket on ubuntu 18.04

I installed Anaconda3 on ubuntu and changed the path to ~/anaconda/bin in .bashrc file then I'm trying to install keras It's throwing this error.
hemanth#specter:~$ python3 -m pip install keras
Traceback (most recent call last):
File "/home/hemanth/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "/home/hemanth/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/__main__.py", line 16, in <module>
from pip._internal import main as _main # isort:skip # noqa
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_internal/__init__.py", line 19, in <module>
from pip._vendor.urllib3.exceptions import DependencyWarning
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/__init__.py", line 8, in <module>
from .connectionpool import (
File "/home/hemanth/anaconda3/lib/python3.7/site-packages/pip/_vendor/urllib3/connectionpool.py", line 7, in <module>
from socket import error as SocketError, timeout as SocketTimeout
File "/home/hemanth/anaconda3/lib/python3.7/socket.py", line 49, in <module>
import _socket
ModuleNotFoundError: No module named '_socket'
I tried this command and it is working fine.
however, try to install socket using pip install sockets and then again try installing keras.

Pyinstaller 3.4 Not Working on Windows 10 with Python 2.7

I have recently reinstalled Windows 10. I am using Python 2.7 and trying to make a small executable using Pyinstaller 3.4. and I get the following error:
C:\python_programs\py_live>pyinstaller g_uplink.py
Traceback (most recent call last):
File "C:\Python27\Lib\runpy.py", line 162, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python27\Lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\Python27\Scripts\pyinstaller.exe\__main__.py", line 5, in <module>
File "C:\Python27\Lib\site-packages\PyInstaller\__init__.py", line 16, in <module>
from . import compat
File "C:\Python27\Lib\site-packages\PyInstaller\compat.py", line 212, in <module>
from win32ctypes.pywin32 import pywintypes # noqa: F401
File "C:\Python27\Lib\site-packages\win32ctypes\pywin32\__init__.py", line 11, in <module>
from win32ctypes.pywin32 import win32api
File "C:\Python27\Lib\site-packages\win32ctypes\pywin32\win32api.py", line 12, in <module>
from win32ctypes.core import (
File "C:\Python27\Lib\site-packages\win32ctypes\core\__init__.py", line 36, in load_module
module = importlib.import_module(self.redirect_module)
File "C:\Python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\Lib\site-packages\win32ctypes\core\cffi\_dll.py", line 19, in <module>
""")
File "C:\Python27\Lib\site-packages\cffi\api.py", line 107, in cdef
self._parser.parse(csource, override=override, packed=packed)
File "C:\Python27\Lib\site-packages\cffi\cparser.py", line 167, in parse
self._internal_parse(csource)
File "C:\Python27\Lib\site-packages\cffi\cparser.py", line 173, in _internal_parse
ast, macros, csource = self._parse(csource)
File "C:\Python27\Lib\site-packages\cffi\cparser.py", line 130, in _parse
self.convert_pycparser_error(e, csource)
File "C:\Python27\Lib\site-packages\cffi\cparser.py", line 159, in convert_pycparser_error
raise api.CDefError(msg)
cffi.api.CDefError: cannot parse "HMODULE WINAPI LoadLibraryExW(LPCTSTR lpFileName, HANDLE hFile, DWORD dwFlags);"
:16:16: before: LoadLibraryExW
Does anyone know what is going on? It worked fine with the same file before reinstalling everything.
I ended up just downgrading Pyinstaller to 3.3 and that worked fine for my application.
pip install pyinstaller==3.3
Note: 3.0 also works as stated in my comment. I successfully tried 3.3 and am now using it because its newer.
As per Mike's own input, installing PyInstaller 3.0 will fix the problem. Just tried on Win7 Enterprise and it works just fine.

Categories