Can't seem to get imports to work. I've installed using
pip install pyperclip
I can can confirm that it was successfully installed:
But then when attempt to confirm in in the Shell:
Is there another step to importing that I'm just missing?
Your problem is that pip is installing for the global (all users) version of python, and you're using a version of python installed for only your user c:\Users\bbarker\AppData\Local\Programs\Python\Python36. You'll want to either use the global install instead c:\program files (x86)\python36-32 or change your pip defaults as described here.
You'll notice the folder where pip told you where pyperclip was installed does not show up in sys.path. Therefore python does not know to search there for libraries. Those few file paths you did have in your sys.path are automatically generated defaults that are relative to the install directory of the particular instance of python you're currently using. If you use the instance in your \program files (x86)\ folder, the paths will be relative to that folder instead
tldr;
You have 2 instances of python installed, and you're installing libraries to one and using the other.
Related
I tried to install the keras_contrib package in a virtual machine which does not allow internet access. So I manually unzip the package, navigate to folder and using python setup.py install to install it. After that I can find the package using pip list, however when I import the package cannot be found. And I cannot find the package folder in the anaconda/lib/site-packages.
(link of the package: https://github.com/keras-team/keras-contrib)
These are the screenshots at the beginning and ending during installation.
Any suggestion? Thanks very much.
You should look at your $PYTHONPATH environment variables. If you are using Mac or Linux, write which python command on your terminal. Also, you can look at the link below for a setup that is similar to your problem
https://github.com/sparklingpandas/sparklingpandas/wiki/setup.py-Install-for-Anaconda-Python
I built a python3 package called gender_univ using the Anaconda conda build command. I uploaded the package to the Anaconda cloud and then installed it into my conda environment. Though the package shows up in the list of installed packages when I type conda list, whenever I try to access the package using import gender_univ I get the error no module named gender_univ.
I want to understand why I can't seem to import a package that is apparently installed in my conda virtual environment? Any suggestions.
First, I would check that you are using the correct python (i.e. which python and confirm that it is the python in your conda environment). Next, you can check if your package is in the site-packages directory of that same python.
The most likely thing, I'd bet, is that the conda package doesn't include everything correctly. Are you sure that you have a build.sh (or bld.bat if you are on windows) and a setup.py? Did you try expanding your built conda package and looking for your python classes in there?
If you expand your built conda package, probably something like gender_univ-VERSION-py35_0.tar.bz2, you should see a lib/python3.5/site-packages/gender_univ directory (i.e. python package). Do you? If not, then the failure is with your building.
I have just started to use python (within Windows, 64bit) - and I have a basic question on how to install external packages within the anaconda / spyder environment. I understand that for most packages one can simply use “conda install bunnies”. However, certain packages are not in the anaconda repository, and might have be installed externally (e.g. from github). For those packages, in order to have spyder to recognize this package – does one only in addition have to update the PYTHONPATH manager in Spyder to include the directory (e.g. c:\users\bunnies) in which one has downloaded this package? Or should one take additional steps / is there a faster way?
You have several options to use packages that are not (yet) available via conda install:
1.) If the respective package is on PyPi you can build it as described in the manual.
2.) If building from scratch doesn't work and the package is on PyPi you can also try an installation via pip. Not that you have to use the pip in your Anaconda distribution and not the one of your systems Python installation.
3.) If you want to include external packages or local folders that contain Python-scripts you can do the following.
3.1.) Use the sys module and append the required package/folder to the path:
import sys
sys.path.append(r'/path/to/my/package')
3.2) Or put the modules into into site-packages, i.e. the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages which is always on sys.path. (Source)
3.3) Or add a .pth file to the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages. This can be named anything (it just must end with .pth). A .pth file is just a newline-separated listing of the full path-names of directories that will be added to your path on Python startup. (Source)
Good luck!
I have looked everywhere and can't find where the packages are installed.
Further, are the packages from pip, modules, libraries or just packages in python terminology?
Use this command to list global packages with their locations:
pip list -v
# output example (windows 10):
# Package Version Location Installer
# ------------------------- --------- ---------------------------------------------------------------- ---------
# adal 0.4.5 c:\users\test\appdata\roaming\python\python36\site-packages pip
# aiocache 0.10.0 c:\program files\python36\lib\site-packages pip
When using virtual environment the local packages is located in project folder:
<project folder>\venv\Lib\site-packages
for python 3.X default location C:\Users\username \AppData\Local\Programs\Python\Python36\Lib\site-packages
From the docs
Python usually stores its library (and thereby your site-packages folder) in the installation directory. So, if you had installed Python to C:\Python\, the default library would reside in C:\Python\Lib\ and third-party modules should be stored in C:\Python\Lib\site-packages.
It depends on how/where your python was installed.
For example:
if you are using Conda for your python, you will most likely find your packages in the default location of:
c:\users\<username>\miniconda3\lib\site-packages
Whereas, if you installed Python3.8 as a stand-alone, you will find it under:
C:\Users\<username>\AppData\Roaming\Python\Python38\site-packages\
where if you install a simply pip package (that did not use any specific locations), and just having some scripts, it will end up in:
C:\Python38\Scripts\
Noting that if the script depend on libraries, it will probably not work, as they will not be found from this location, if installed on Windows, and not taking this into account.
Or if you used Cygwin, they'll end up in one of:
/usr/lib/python3.8/site-packages
/usr/local/lib/python3.8/site-packages
Again, you best bet is to check with:
pip -V
pip list -v
There is also a pip package called pip-date that contain a utility called pipbyday that will show you the location of each package and the installation time.
import nest gives the 'no module named nest' error when it is in the $PATH, which means that there is a /opt/nest/lib/python2.7/site-packages: in my system $PATH. At this location there is a directory named nest and the structure inside the nest directory is looks like:
, where there is an __init__.py obviously. So why can't python find nest?
more information:
I am sure that I installed nest with python2.7, and run it with the same python2.7.
According to the docs, there are several ways to install python packages:
using distutils - running python setup.py install installs the package to site-packages of your current distribution;
passing --user to setup.py install installs module to ~/.local/lib/python2.7/site-packages on Unix, and this directory in under normal conditions always included in sys.path;
passing --home=$HOME to setup.py install installs module under $HOME directory. This directory should be included to sys.path explicitly;
modifying python search path:
you can do either
import sys
sys.path.append('/opt/nest/lib/python2.7/site-packages')
in the beginning of your script; or your can add
PYTHONPATH=/opt/nest/lib/python2.7/site-packages
export PYTHONPATH
in the end of your ~/.bash_profile file.
UPDATE:
Just tried to install nest and found that it comes in two flavours - 32bit (under /opt/nest/lib) and 64bit (under /opt/nest/lib64). You might have tried to use 32-bit python package with 64-bit python distribution. Try to change the string in ./zshrc to
PYTHONPATH=/opt/nest/lib64/python2.7/site-packages and see if it works. It works for me at least.
To set relevant environment variables correctly, NEST installs have a config that you can just source
source <installpath>/bin/nest_vars.sh
That sets the PATH and PYTHONPATH correctly and points NEST to the right directories for dynamically loaded content (modules, help pages, …)