I having trouble importing PyTorch in my jetson nano (jetpack 4.4, Cuda 10.2.89), I have successfully installed it from .whl file and it is in my pip3 lib. But when I import it, it shows this error. Please help.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/parikshit/.local/lib/python3.6/site-packages/torch/__init__.py", line 188, in <module>
_load_global_deps()
File "/home/parikshit/.local/lib/python3.6/site-packages/torch/__init__.py", line 141, in _load_global_deps
ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmpi_cxx.so.20: cannot open shared object file: No such file or directory```
Try to do the following:
cd /home/parikshit/.local/lib/python3.6/site-packages/torch
ls
# You should find a .so file. Run the following command on that file
ldd the_file_you_found.so
#In the output you should see "not found"
#To find out which apt packages provide this .so:
sudo apt install apt-file
sudo apt-file update
#Now search for that "not found" library file. Example:
apt-file search blah.so.100
#In the first part of each line you will see the name of the file that you need to install. Example:
sudo apt install lib-hello
#Enjoy!
cd /home/parikshit/.local/lib/python3.6/site-packages/torch ls
# You should find a .so file. Run the following command on that file ldd the_file_you_found.so
#In the output you should see "not found"
#To find out which apt packages provide this .so: sudo apt install apt-file sudo apt-file update
#Now search for that "not found" library file. Example: apt-file search blah.so.100
#In the first part of each line you will see the name of the file that you need to install. Example: sudo apt install lib-hello
#Enjoy!
The previous answer resolve my issue about not finding libmpi_cxx.so.20 on Jetson Nano but I have encountered a different error while importing torch.
Error is: from torch._C import * ImportError: numpy.core.multiarray
failed to import
If you have problem importing torch because of failed to import numpy follow the step below.
pip install numpy -I
You can check the issue on GitHub for details.
Related
When trying to install a package for Python 3 (in Ubuntu), using pip3 install packageName (or sudo pip3 install packageName), I get the following error message:
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 33, in vendored
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
I have been reading for days and have tried the following WITHOUT any success:
Un-installing and re-installing pip3 using the following code: sudo apt-get remove python3-pip followed by sudo apt-get install python3-pip. This was suggested in several posts that say that sometimes pip3 doesn't install properly for Ubuntu. However, it didn't work.
Other post suggested it was an ssl package problem and that if the ssl package doesn't load on Python3, that's the issue. However the following command does not raise any error: python3 -c "import ssl".
Some other post suggested the problem was with the requests package. I then tried sudo apt-get remove python3-requests followed by sudo apt-get install python3-requests also to no avail.
Other information you may need:
pip3 --version gives me the same error reported above.
dpkg -L python3-pip gives me the following information:
/.
/usr
/usr/lib
/usr/lib/python3
/usr/lib/python3/dist-packages
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/PKG-INFO
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/dependency_links.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/not-zip-safe
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/requires.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/entry_points.txt
/usr/lib/python3/dist-packages/pip-8.1.1.egg-info/top_level.txt
/usr/lib/python3/dist-packages/pip
/usr/lib/python3/dist-packages/pip/baseparser.py
/usr/lib/python3/dist-packages/pip/__main__.py
/usr/lib/python3/dist-packages/pip/req
/usr/lib/python3/dist-packages/pip/req/req_set.py
/usr/lib/python3/dist-packages/pip/req/req_install.py
/usr/lib/python3/dist-packages/pip/req/__init__.py
/usr/lib/python3/dist-packages/pip/req/req_file.py
/usr/lib/python3/dist-packages/pip/req/req_uninstall.py
/usr/lib/python3/dist-packages/pip/index.py
/usr/lib/python3/dist-packages/pip/status_codes.py
/usr/lib/python3/dist-packages/pip/utils
/usr/lib/python3/dist-packages/pip/utils/setuptools_build.py
/usr/lib/python3/dist-packages/pip/utils/appdirs.py
/usr/lib/python3/dist-packages/pip/utils/outdated.py
/usr/lib/python3/dist-packages/pip/utils/ui.py
/usr/lib/python3/dist-packages/pip/utils/logging.py
/usr/lib/python3/dist-packages/pip/utils/encoding.py
/usr/lib/python3/dist-packages/pip/utils/deprecation.py
/usr/lib/python3/dist-packages/pip/utils/__init__.py
/usr/lib/python3/dist-packages/pip/utils/filesystem.py
/usr/lib/python3/dist-packages/pip/utils/hashes.py
/usr/lib/python3/dist-packages/pip/utils/build.py
/usr/lib/python3/dist-packages/pip/compat
/usr/lib/python3/dist-packages/pip/compat/dictconfig.py
/usr/lib/python3/dist-packages/pip/compat/__init__.py
/usr/lib/python3/dist-packages/pip/compat/ordereddict.py
/usr/lib/python3/dist-packages/pip/models
/usr/lib/python3/dist-packages/pip/models/index.py
/usr/lib/python3/dist-packages/pip/models/__init__.py
/usr/lib/python3/dist-packages/pip/vcs
/usr/lib/python3/dist-packages/pip/vcs/bazaar.py
/usr/lib/python3/dist-packages/pip/vcs/subversion.py
/usr/lib/python3/dist-packages/pip/vcs/mercurial.py
/usr/lib/python3/dist-packages/pip/vcs/__init__.py
/usr/lib/python3/dist-packages/pip/vcs/git.py
/usr/lib/python3/dist-packages/pip/cmdoptions.py
/usr/lib/python3/dist-packages/pip/basecommand.py
/usr/lib/python3/dist-packages/pip/commands
/usr/lib/python3/dist-packages/pip/commands/completion.py
/usr/lib/python3/dist-packages/pip/commands/install.py
/usr/lib/python3/dist-packages/pip/commands/hash.py
/usr/lib/python3/dist-packages/pip/commands/uninstall.py
/usr/lib/python3/dist-packages/pip/commands/__init__.py
/usr/lib/python3/dist-packages/pip/commands/list.py
/usr/lib/python3/dist-packages/pip/commands/search.py
/usr/lib/python3/dist-packages/pip/commands/show.py
/usr/lib/python3/dist-packages/pip/commands/download.py
/usr/lib/python3/dist-packages/pip/commands/wheel.py
/usr/lib/python3/dist-packages/pip/commands/freeze.py
/usr/lib/python3/dist-packages/pip/commands/help.py
/usr/lib/python3/dist-packages/pip/_vendor
/usr/lib/python3/dist-packages/pip/_vendor/__init__.py
/usr/lib/python3/dist-packages/pip/operations
/usr/lib/python3/dist-packages/pip/operations/__init__.py
/usr/lib/python3/dist-packages/pip/operations/freeze.py
/usr/lib/python3/dist-packages/pip/__init__.py
/usr/lib/python3/dist-packages/pip/locations.py
/usr/lib/python3/dist-packages/pip/pep425tags.py
/usr/lib/python3/dist-packages/pip/exceptions.py
/usr/lib/python3/dist-packages/pip/download.py
/usr/lib/python3/dist-packages/pip/wheel.py
/usr/share
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/pip3.1.gz
/usr/share/doc
/usr/share/doc/python3-pip
/usr/share/doc/python3-pip/copyright
/usr/bin
/usr/bin/pip3
/usr/share/doc/python3-pip/changelog.Debian.gz
How can I make pip3 work?
NOTE: pip for Python2 works just fine.
================================================
EDIT:
When trying to import setuptools in Python3 I get the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extern.six.moves import filterfalse, map
File "/usr/lib/python3/dist-packages/setuptools/extern/__init__.py", line 1, in <module>
from pkg_resources.extern import VendorImporter
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2927, in <module>
#_call_aside
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2913, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in _initialize_master_working_set
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 956, in subscribe
callback(dist)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2952, in <lambda>
add_activation_listener(lambda dist: dist.activate())
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2515, in activate
declare_namespace(pkg)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2097, in declare_namespace
_handle_ns(packageName, path_item)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2047, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 2066, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
When running the following command sed -n '31,37p' < /usr/lib/python3/dist-packages/pip/_vendor/__init__.py in the terminal, I get the following:
try:
__import__(vendored_name, globals(), locals(), level=0)
except ImportError:
try:
__import__(modulename, globals(), locals(), level=0)
except ImportError:
===========================================
EDIT2:
My python3 --version is Python 3.5.2.
List of installed packages obtained running the code ls /usr/lib/python3/dist-packages.
apport
apport_python_hook.py
apt
aptdaemon
apt_inst.cpython-35m-x86_64-linux-gnu.so
apt_pkg.cpython-35m-x86_64-linux-gnu.so
aptsources
AptUrl
apturl-0.5.2.egg-info
beautifulsoup4-4.4.1.egg-info
blinker
blinker-1.3.egg-info
Brlapi-0.6.4.egg-info
brlapi.cpython-35m-x86_64-linux-gnu.so
bs4
cairo
_cffi_backend.cpython-35m-x86_64-linux-gnu.so
chardet
chardet-2.3.0.egg-info
checkbox_support
checkbox_support-0.22.egg-info
CommandNotFound
command_not_found-0.3.egg-info
cryptography
cryptography-1.2.3.egg-info
cups.cpython-35m-x86_64-linux-gnu.so
cupsext.cpython-35m-x86_64-linux-gnu.so
curl
cycler-0.9.0.egg-info
cycler.py
dateutil
dbus
_dbus_bindings.cpython-35m-x86_64-linux-gnu.so
_dbus_glib_bindings.cpython-35m-x86_64-linux-gnu.so
deb822.py
debconf.py
debian
debian_bundle
decorator-4.0.6.egg-info
decorator.py
defer
defer-1.0.6.egg-info
DistUpgrade
easy_install.py
feedparser-5.1.3.egg-info
feedparser.py
feedparser_sgmllib3.py
gi
guacamole
guacamole-0.9.2.egg-info
hpmudext.cpython-35m-x86_64-linux-gnu.so
html5lib
html5lib-0.999.egg-info
httplib2
httplib2-0.9.1.egg-info
idna
idna-2.0.egg-info
janitor
jinja2
Jinja2-2.8.egg-info
jwt
LanguageSelector
language_selector-0.1.egg-info
language_support_pkgs.py
louis
louis-2.6.4.egg-info
lsb_release.py
lxml
lxml-3.5.0.egg-info
mako
Mako-1.0.3.egg-info
markupsafe
MarkupSafe-0.23.egg-info
matplotlib
matplotlib-1.5.1.egg-info
matplotlib-1.5.1-nspkg.pth
mpl_toolkits
networkx
networkx-1.11.egg-info
numexpr
numexpr-2.4.3.egg-info
numpy
numpy-1.11.0.egg-info
NvidiaDetector
oauthlib
oauthlib-1.0.3.egg-info
Onboard
onboard-1.2.0.egg-info
orca
padme
padme-1.1.1.egg-info
pandas
pandas-0.17.1.egg-info
pcardext.cpython-35m-x86_64-linux-gnu.so
pexpect
pexpect-4.0.1.egg-info
PIL
Pillow-3.1.2.egg-info
pip
pip-8.1.1.egg-info
pkg_resources
plotly
plotly-1.9.5.egg-info
problem_report.py
ptyprocess
ptyprocess-0.5.egg-info
pyasn1
pyasn1-0.1.9.egg-info
pyatspi
__pycache__
pycups-1.9.73.egg-info
pycurl-7.43.0.egg-info
pycurl.cpython-35m-x86_64-linux-gnu.so
pygobject-3.20.0.egg-info
pygtkcompat
PyJWT-1.3.0.egg-info
pylab.py
pyparsing-2.0.3.egg-info
pyparsing.py
python_apt-1.1.0.b1_ubuntu0.16.04.1.egg-info
python_dateutil-2.4.2.egg-info
python_debian-0.1.27.egg-info
python_systemd-231.egg-info
pytz
pytz-2014.10.egg-info
pyxdg-0.25.egg-info
PyYAML-3.11.egg-info
Quirks
reportlab
reportlab-3.3.0.egg-info
requests
requests-2.9.1.egg-info
scanext.cpython-35m-x86_64-linux-gnu.so
scipy
scipy-0.17.0.egg-info
sessioninstaller
sessioninstaller-0.0.0.egg-info
setuptools
setuptools-20.7.0.egg-info
six-1.10.0.egg-info
six.py
softwareproperties
speechd
speechd_config
systemd
system_service-0.3.egg-info
tables
tables-3.2.2.egg-info
UbuntuDrivers
ubuntu_drivers_common-0.0.0.egg-info
UbuntuSystemService
ufw
ufw-0.35.egg-info
unattended_upgrades-0.1.egg-info
unity_scope_calculator-0.1.egg-info
unity_scope_chromiumbookmarks-0.1.egg-info
unity_scope_colourlovers-0.1.egg-info
unity_scope_devhelp-0.1.egg-info
unity_scope_firefoxbookmarks-0.1.egg-info
unity_scope_gdrive-0.7.egg-info
unity_scope_manpages-0.1.egg-info
unity_scope_openclipart-0.1.egg-info
unity_scope_texdoc-0.1.egg-info
unity_scope_tomboy-0.1.egg-info
unity_scope_virtualbox-0.1.egg-info
unity_scope_yelp-0.1.egg-info
unity_scope_zotero-0.1.egg-info
unohelper.py
uno.py
UpdateManager
urllib3
urllib3-1.13.1.egg-info
usbcreator
usb_creator-0.3.0.egg-info
wheel
wheel-0.29.0.egg-info
xdg
xdiagnose
xdiagnose-3.8.4.1.egg-info
xkit
xkit-0.0.0.egg-info
xlsxwriter
XlsxWriter-0.7.3.egg-info
yaml
_yaml.cpython-35m-x86_64-linux-gnu.so
This solved it for me:
curl -sS https://bootstrap.pypa.io/get-pip.py | python3
try use virtualenv for every specific project not messing with ubuntu subsystem.
I got this error on WSL Ubuntu and the most upvoted solution didn't work for me.
The one that works:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall
Thanks #s_s.411
I solve this problem with the following commands:
curl -sS https://bootstrap.pypa.io/get-pip.py | sudo python3
type pip3
hash -r
pip3
I ran into the same problem, on Ubuntu 16.04, using the system python 3.5.2 like you, with pip installed via apt (sudo apt install python3-pip) like you, having installed some packages in my home directory with pip3 install --user like you (documented in your chat with hoefling).
The solution was as follows:
Temporarily move away all packages installed with pip3 install --user:
mv ~/.local/lib/python3.5/site-packages{,_backup}
This made pip3 work again, but of course I wanted to keep the packages. (Note: just moving out setuptools was not enough; I am not sure which constellation of packages caused this.)
Install an upgraded pip into home directory:
pip3 install --upgrade --user pip
Now the pip3 command fails (ImportError: cannot import name 'main') because it's still called from the old /usr/bin/pip3 location in the current shell, as indicated by type pip3. To solve this, run:
hash -r
Alternatively, you can always fall back to typing python3 -m pip instead of pip3.
Restore the packages:
mv ~/.local/lib/python3.5/site-packages{_backup/*,}
rmdir ~/.local/lib/python3.5/site-packages_backup
Now pip was working, but python3 -m 'import setuptools' failed with the same exception you saw, AttributeError: '_NamespacePath' object has no attribute 'sort'. This could be solved by uninstalling, then reinstalling the setuptools package in my home directory (uninstalling alone was not enough):
pip3 uninstall setuptools
pip3 install --user --upgrade setuptools
Finally, pip3 and the python3 -c 'import setuptools' are fine.
No module named 'pip._vendor.packaging'
The solution for me was to uninstall the system pipenv (installed with the package manager, pacman), and install pipenv from pip (which is managed with pyenv):
pip install pipenv
I no longer have issues when running pipenv install.
I tried all fixes on this page and it didn't work, finally I found out my virtualenv was broken and I had to reinstall the virtualenv like so
deactivate - deactivate first to be safe
virtualenv --python=/usr/bin/python3.8 /path/to/my_virtualenv_python3
source /path/to/my_virtualenv_python3/bin/activate - activate the env egain
Of course replace /path/to/my_virtualenv_python with your own path and python3.8 with a custom version of python if you don't use version 3.8 :)
Also please note this may or may not remove already installed packages, so just reinstall every requirements.txt you need afterwards.
I also have same problem and I solved it by this command.
pip uninstall pkg-resources==0.0.0
I use an old virtualenv version, it is OK.
The old version is 15.1.0.
I had a similar issue with Debian 11, my Debian has been updated to major releases several times and it looks like some files were not removed. I had to clean them:
# remove pip
sudo apt purge python3-pip
# check that the files don't belong to any package
dpkg -S /usr/share/python-wheels/* /usr/share/python-support/private/*
# remove the files
sudo rm -rfv /usr/share/python-wheels/ /usr/share/python-support/private/
# remove old files since Python is now 3.9
rm -rfv ~/.local/lib/python3.7/
# reinstall pip
sudo apt install python3-pip
And pip worked again.
I recently upgraded from Ubuntu 17.04 to 17.10 in order to be able receive the patches for meltdown. This upgrade automatically bumped me from python3.5 to python3.6, which I don't have any problem with. However, I do have to go through and reinstall all the little tools I used. One is being troublesome.
I use a tool called tmuxp, and the official install instructions are pip install --user tmuxp. However, it seems that some time ago I install tmuxp globally on my python3.5, and it now has an executable in my /user/local/bin:
➜ maynard#buddha ~ which tmuxp
/usr/local/bin/tmuxp
This means that even after running pip install --user tmuxp, when I run tmuxp I get a DistributionNotFound error.
➜ maynard#buddha ~ tmuxp
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 658, in _build_master
ws.require(__requires__)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 972, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 863, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (tmuxp 1.3.5 (/home/maynard/.local/lib/python3.6/site-packages), Requirement.parse('tmuxp==1.3.2'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/tmuxp", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3049, in <module>
#_call_aside
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3033, in _call_aside
f(*args, **kwargs)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 3062, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 660, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 673, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/lib/python3/dist-packages/pkg_resources/__init__.py", line 858, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'tmuxp==1.3.2' distribution was not found and
is required by the application
So the old python3.5 tmuxp binary is going and looking in the new python3.6 site-packages for an older version of itself. This should be an easy fix. Simply uninstall the python3.5 version of tmuxp. But when I use pip3.5 is tries to uninstall the python3.6 tmuxp.
pip3.5 uninstall tmuxp
Uninstalling tmuxp-1.3.5:
/home/maynard/.local/bin/tmuxp
/home/maynard/.local/lib/python3.6/site-packages/tmuxp-1.3.5.dist-info/DESCRIPTION.rst
...
/home/maynard/.local/lib/python3.6/site-packages/tmuxp/workspacebuilder.py
In fact, a pip3.5 list doesn't even show tmuxp, but I can see it in /usr/local/lib/python3.5/dist-packages!
ls /usr/local/lib/python3.5/dist-packages
click kaptan powerline
click-6.7.dist-info kaptan-0.5.8.egg-info powerline_status-2.6.egg-info
colorama libtmux tmuxp
colorama-0.3.9.dist-info libtmux-0.7.4.egg-info tmuxp-1.3.2.egg-info
Invoking sudo doesn't work either. sudo ~/.local/bin/pip3.5 uninstall tmuxp once again tries to uninstall the python3.6 version of tmuxp.
I know I could just delete the binary in /usr/local/bin/tmuxp... But I want to know how I got myself into this mess and how I can get out of it cleanly.
tmuxp didn't exist officially in Ubuntu until 18.04 bionic (LTS).
/usr/lib/python3/dist-packages
Do you have tmuxp installed through apt / apt-get through some other method? If so, see what sudo apt-get remove tmuxp does.
If you don't have the apt package to tmuxp, I'm concerned about your system's python installation.
Backtracking using history(1) + grep(1)
To find out how and why the system's python packages got borked depends on the commands you ran in the past. Hopefully you still have a shell history of when you installed.
If you look in your Bash history for tmuxp by piping to grep(1), e.g. history | grep tmuxp, can you see commands for how you could have ended up with it previously?
My hunch is you may have used easy_install, which in 2022 isn't used anymore.
Cleaning up old packages
I prefer clean installs over upgrades with Ubuntu, namely to avoid issues like this. It's not as painful in recent releases.
#hoefling's comment is on track. It seems you need to install python 3.5 again. This answer has some ways to get 3.5 working again. Afterwards, you can then install it.
I am trying to install mongo-connector on Amazon-EC2 instance using the following command:
pip install mongo-connector
But following error flashes up everytime:
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 31 7, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 742 , in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 1 15, in remove
renames(path, new_path)
File "/usr/local/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib64/python2.7/shutil.py", line 300, in move
rmtree(src)
File "/usr/lib64/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/usr/lib64/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/usr/lib/python2.7/dist-packages/request s/sessions.pyo'
I thought this might be some issue with root permissions, so I tried :
sudo pip install mongo-connector
But this says ,
sudo: pip: command not found
I am using pip 8.1.2, Python 2.7.12.
Any help would be appreciated!
I solved this by using the following command:
sudo `which pip`install mongo-connector
You shouldn't be using sudo to install packages with pip. While it works, it's modifying files that should be managed by your OS package manager which isn't desirable -- see also https://stackoverflow.com/a/21056000/1931274.
If you pass --user to that command, you'll be able to install without permission issues:
pip install --user mongo-connector
Moreover, newer versions of pip (installable via pip install --user pip or using get-pip.py) print a better, more helpful message when such errors occur.
For windows download required precompiled python packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ and pip install <point to the downloaded file>.
One more way to solve this is:
sudo bash
now you are in a bash with root privileges so now you can execute
pip install mongo-connector
without any permission issues
I tried to install BeautifulSoup 4
It worked after I typed following into my mac terminal
$ easy_install beautifulsoup4
$ pip install beautifulsoup4
But when I imported it in my python,
from bs4 import BeautifulSoup
the screen always shows the Error:
ImportError: cannot import name 'HTMLParseError'
Then I googled the error and found by typing following code in terminal could solve the problem
pip install --upgrade beautifulsoup4
But after I typed,it was shown
Exception:
Traceback (most recent call last):
File "//anaconda/lib/python3.5/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "//anaconda/lib/python3.5/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "//anaconda/lib/python3.5/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "//anaconda/lib/python3.5/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "//anaconda/lib/python3.5/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "//anaconda/lib/python3.5/site-packages/pip/wheel.py", line 346, in move_wheel_files
clobber(source, lib_dir, True)
File "//anaconda/lib/python3.5/site-packages/pip/wheel.py", line 324, in clobber
shutil.copyfile(srcfile, destfile)
File "//anaconda/lib/python3.5/shutil.py", line 115, in copyfile
with open(dst, 'wb') as fdst:
PermissionError: [Errno 13] Permission denied: '//anaconda/lib/python3.5/site-packages/bs4/__init__.py'
I have no idea how to fix it. Thanks for someone help
Easiest way to solve this is using Sudo.
sudo pip install --upgrade beautifulsoup4
However sudo is not always recommended to do so, you should not install arbitrary code as root.
My recommendation would be to create a virtualenv, install the packages play with before using sudo to install them as root.
You can use virtualenvwrapper
sudo pip install virtualenvwrapper
mkvirtualenv
workon
python setup.py install
I'm trying to install Tweepy on an Ubuntu VM and I'm running into way more issues than I should be. My first step was to successfully get pip installed. After that I tried:
pip install tweepy
which returns:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 3020, in <module>
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 616, in _build_master
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 629, in _build_from_requirements
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 807, in resolve
pkg_resources.DistributionNotFound: pip==1.5.4
The most that I can gather from that error message is that it can't find pip version 1.5.4. However, if I ask it whereis pip it returns:
pip: /usr/local/bin/pip2.7 /usr/local/bin/pip /usr/share/man/man1/pip.1.gz
So I know pip is installed. I decided to try the other method listed and do
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
But that only seems to partially install with error messages returning. Trying whereis tweepy after that method returns nothing.
Can anyone make sense of why this simple install isn't working for me?
This issue was resolved by using another fresh Ubuntu VM install and once again trying the manual installation by using
git clone https://github.com/tweepy/tweepy.git
cd tweepy
python setup.py install
For whatever reason, it now works. The answer is officially voodoo.