Where did my python module install to? - python

I'm running python 3.6 via anaconda 3, using Visual Studio Code.
I followed instructions like these (Interactive Brokers API install) and downloaded the package to a local directory of mine say: c:\dev\pyib, so now the code is in c:\dev\pyib\IbPy-master
I open that directory in command line and run
python setup.py install
All runs ok.
But then my program, which is in c:\dev\pyib says Module not found. (In my case ibapi). The linter is also showing red.
There is no other python installed on this pc.
Where did the package install to? and how do I check that? What will I find where the package installed itself to that shows me its there?
Or do I have to use a trial-and-error with the linter and sys.path.append()? (I tried that with the directory where the files are downloaded to - to no avail)
I'm trying to set up the PYTHONPATH using the "env" in launch.json from Visual Studio Code, as shown in this unaccepted answer.
Current sys.path:
'c:\\dev\\pyIb',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\python36.zip',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\DLLs',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-
packages',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Babel-2.5.0-py3.6.egg',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\win32\\lib',
'C:\\Users\\user\\AppData\\Local\\Continuum\\anaconda3\\lib\\site-packages\\Pythonwin'
I deleted the ib directory and re-ran the install. The last line says: Writing C:\Users\user\AppData\Local\Continuum\anaconda3\Lib\site-pac‌​kages\IbPy2-0.8.0-py‌​3.6.egg-info So is the location of the egg-info the location of my undetected module? The actual folder in the site-packages is called ib.
Or could my problems be because of a difference in Lib vs. lib with the lowercase in the sys.path and the uppercase in the actual directory?
But the real question here is still: HOW DO I KNOW WHERE the package was installed what should I search for?

This answer is specific for anaconda3 Python and packages installed using python setup.py install (which is actually using distutils)
Take a look at anaconda3\Lib\site-packages you should see a directory for the package you installed.
The way to know for sure where your package is, is by doing a pip list then trying to pip uninstall and re-install again using the python setup.py install: Here are the detailed instructions:
When uninstalling, pip will tell you it cannot because it was done via distutils.
You'll get a message like this:
DEPRECATION: Uninstalling a distutils installed project (ibpy2) has been deprecated and will be removed in a future version.
This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
You'll be prompted to continue anyway. If you choose No, then you can find the directory in
C:\Users\<yourusername>\AppData\Local\Continuum\anaconda3\Lib\site-packages
Thanks to Emanuel Mtali for pointing me in the right direction
Some more information:
The problem I had was due to a stupid mistake of mine. I was running setup of a different (but related) package not used anymore. IbPy2 instead of TwsAPI. I was supposed to run the setup.py of the package installed via the latest version of the MSI from IB, and NOT the IbPy2 package. :-(

Related

I have a error on installing CPLEX 12.10 to Python 3.8

I am trying to install CPLEX studio 12.10 to Python 3.8. I'm using Visual studio code editor.
Referring to https://www.ibm.com/support/knowledgecenter/en/SSSA5P_12.8.0/ilog.odms.cplex.help/CPLEX/GettingStarted/topics/set_up/Python_setup.html, I use the command "python setup.py install --home C:\Program Files\IBM\ILOG\CPLEX_Studio1210\cplex\python\3.7\x64_win64". But error " can't open file 'setup.py': [Errno 2] No such file or directory" is appeared.
How to solve this problem?. I also checked that setup.py is in the above folder.
You need to find setup.py first by going the folder that CPLEX is installed (use the path you wrote after install --home). Furthermore, the path after install --home is to the directory where your Python is installed. See this answer for details.
Also, CPLEX 12.10 doesn't support Python 3.8 for now.
There is a workaround for this problem if you are able to modify the underlying python library shipped with CPLEX. Essentially, the python interface is the same, but the program will check your python version and prevent you from installing and using it if the version does not match.
Go to /path/to/installation/cplex/python, you should see 2 directories (3.6 and 3.7). Make a copy of 3.7 and rename it as your python version, for example, 3.8 or 3.9. In /path/to/installation/cplex/python/<your_python_version>/<your_os>/setup.py and /path/to/installation/cplex/python/<your_python_version>/<your_os>/cplex/_internal/_pycplex_platform.py, remove the code that checks python version.
The above is tested on x86_64 Linux with python 3.9.2 using the official docplex library (you will need to export an environmental variable, see the official documentation). I suppose if you run setup.py to install the cplex python libaray, it should also work. Beware this is not officially supported, and do it at your own risk.

How do I add all include .h files in python directory

I am trying to install PyHook using PIP. When I run the command on cmd pip install pyhook3 I get a C1080 error that tells me there is no such .h file located in my directory. I traced the directory, downloaded the file and it showed me another. I kept doing this until I noticed that there seems to be no end. There seems to be a lot of missing .h files in this includes folder C:\Users\User\AppData\Local\Programs\Python\Python38-32\include directory. I don't want to have to download or copy and paste source code for each of these files. Is there any way to get all of them at once, or am I missing the plot entirely?
pyhook is a Python package with binary dependencies.
When running pip install pyhook3 you download the source and ask your computer to build it so it can be installed. It thus requires a compiler and a set of header files that are apparently missing for you.
A workaround may be to download manually a compiled version of this package and install it.
You can find on this page a set of binary wheel for pyhook (not pyhook3) for python3 (32 or 64 bit). Once you have downloaded the correct .whl, you can install it with pip install the_filename_you_have_downloaded.whl

missing packages in mobaxterm apt-get session

When attempting to install Python in MobaXterm, two packages are not found in the local repository. I have found at least one of them in an external repository and I would like to configure my terminal to use another repository beside the one indicated in the example directory tree as follows:
http://mirrors.kernel.org/sourceware/cygwin/release/cygwin-devel
Either that or I would like to change the package version to one that exists in this location, but then I worry about package versioning issues.
Or a third option would be to download the packages I find in the other locations and install them using the same terminal I used to install the other Python packages.
Here are the two packages with issues:
Installing cygwin-devel
Downloading cygwin-devel-2.7.0-1.tar.xz...
Downloading /home/mobaxterm/.aptcyg/http%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin/release/cygwin-devel/cygwin-devel-2.7.0-1.tar.xz using Windows internet settings
sha512sum: can't open 'cygwin-devel-2.7.0-1.tar.xz': No such file or directory
/bin/apt-cyg: line 476: test: 8f382e85417a4efa951607776be66cf91381e4075bcc4458da40141951305675faff4890bd2723de91483725c5d5bd726128355a2de41a0c743428b2829fe48c: unary operator expected
md5sum: can't open 'cygwin-devel-2.7.0-1.tar.xz': No such file or directory
/bin/apt-cyg: line 479: test: 8f382e85417a4efa951607776be66cf91381e4075bcc4458da40141951305675faff4890bd2723de91483725c5d5bd726128355a2de41a0c743428b2829fe48c: unary operator expected
Checksum did not match, exiting
Installing libexpat1
Downloading libexpat1-2.2.0-0.tar.xz...
Downloading /home/mobaxterm/.aptcyg/http%3a%2f%2fmirrors.kernel.org%2fsourceware%2fcygwin/release/libexpat1/libexpat1-2.2.0-0.tar.xz using Windows internet settings
sha512sum: can't open 'libexpat1-2.2.0-0.tar.xz': No such file or directory
/bin/apt-cyg: line 476: test: a39f95f129fc7abe1e22f71925844dac0160f7c536f01bb8e5cc1f9b23f19266dd95e633a4e44d6b4ad792aa25c2a69b473dd06400ef4e7dab02e88877020455: unary operator expected
md5sum: can't open 'libexpat1-2.2.0-0.tar.xz': No such file or directory
/bin/apt-cyg: line 479: test: a39f95f129fc7abe1e22f71925844dac0160f7c536f01bb8e5cc1f9b23f19266dd95e633a4e44d6b4ad792aa25c2a69b473dd06400ef4e7dab02e88877020455: unary operator expected
Checksum did not match, exiting
Thanks in advance for any insights that might lead me to resolve this and have a clean Python installation.
I found a workaround - hopefully. In essence, the setup.ini file on the repository references a version of the packages that actually does not exist on that repository. After reading up on apt-get I learned that I could pass a legacy flag to get an earlier version of the package installed:
[micro.MSI] ➤ apt-get install --legacy libexpat1
Found package libexpat1
Installing libexpat1
Downloading libexpat1-2.2.0-0.tar.xz...
Unpacking libexpat1-2.2.0-0.tar.xz...
Extracting dependencies for usr/bin/cygexpat-1.dll...
Package libexpat1 requires the following packages, installing cygwin
Package cygwin is already installed, skipping
Package libexpat1 installed.
Rebasing new libraries
This might introduce versioning issues, but the dependency was already there, as it should be since it was installed in the earlier python installation. Now I can see if I can get the other modules installed for my project.
If anyone else has advice about this package management issue, please chime in. I am wondering if I should notify the source repository owners about their setup.ini file pointing to versions that do not exist.

I cannot install dipy library for python, why ? In the description I explain what I did

I went to http://nipy.org/dipy/installation.html and install nibabel, then I when I wanted to install dipy, there where 2 problems:
Wheel was not built
and vcvarshall.bat not found.
What I did ?
Install Setuptools in site-pakcages
download Setuptools-34.3.1-py2.py3-none-any.whl (md5) and save in site-packages
I also try
python setup.py install --compiler=mingw32ç
and
If you get an error saying unable to find vcvarsall.bat then you need to create a file called pydistutils.cfg in notepad and give it the contents
[build]
compiler=mingw32
But setup.py de system it did not find, and I still have vcvarshall.bat not found.
what I need to do?
I am using, Windows 7, Python 3.5.1 and Anaconda 2.5.0 (64 bit)
You will almost certainly find it easier to install third-party packages if you adopt virtual environments. When done correctly you will then not need admin privileges to install packages into virtualenvs. The HitchHikers' Guide to Python contains more information about this.
The vcvarsall.bat is, I believe, a part of the Visual Studio (the Express version is available at no cost) environment. It's required when you are trying to build a compiled Python extension as described in this article. I'm not sure how that will play with mingw.
So, I installed via ANACONDA but , when I go to python, and I want to import dipy it says: No modle named dipy
Solved ! Well I had python 3.5 and dipy has some issues with that version, so I installed Anaconda with python 2.7 , installed visual c++9 and follow the steps on the web !

Installing a .tar.bz2 in windows

I am a newbie to installing python extensions working on Windows 7, running Python 2.6 - I need to install the Levenshtein library from
http://code.google.com/p/pylevenshtein/downloads/detail?name=python-Levenshtein-0.10.1.tar.bz2&can=2&q=
When I unzip the downloaded file, it gives me the following list of files:
COPYING
gendoc.sh
Levenshtein.c
Levenshtein.h
MANIFEST
NEWS
PKG-INFO
README
setup.cfg
setup.py
StringMatcher.py
How do I install the Levenshtein library so I could import and use it into my python code?
Assuming you have Python already installed on on you PATH, you can do this:
python setup.py install
However, it seems to have a compiled extension so you will probably also need a complete Windows development environment to install that (it is a source distribution). So if you don't it may not work. Your best bet would be to find that as an MSI package, if you can.
Here is quite a large section of the documentation easily found by doing some research.
http://docs.python.org/install/index.html
It appears that you will want to run:
python setup.py install --prefix="\Temp\Python"
to install modules to the \Temp\Python directory on the current drive.
Some more info:
If you don’t choose an installation directory—i.e., if you just run
setup.py install—then the install command installs to the standard
location for third-party Python modules.
The default installation directory on Windows was C:\Program Files\Python under Python 1.6a1, 1.5.2, and earlier.

Categories