Python 3.4.2 AND pip Permission Issues - python

I've been struggling with an issue with Python and pip installs (python version 3.4.2, same with x86 or x64 MSIs, Windows 7 x64). I'm using the CPython installer available from the Python.org website.
When I install, I get the UAC prompt, which I approve, and it installs fine to D:\opt\python34 (along with pip, as added in 3.4.2 installations by default). Then, as standard procedure, I add the install path and Scripts subfolder to the user path variable. Now, the issues are as follows:
Whenever I run python setup.py install inside any package directory, the prompt hangs at writing ... to top_level.txt or writing to dependency_links.txt or etc. (Same issue happens if I create a virtual environment using python -m venv, activate it, and do python setup.py install). Setup.py never succeeds. Pip install also hangs infinitely after giving a warning "manifest_maker: Standard file '-c' not found."
If I remove setuptools, and just use distribute, then "python setup.py install" works.
Kindly assist with ideas/solutions.

After many days of trying a workaround, I finally got down to debugging the setup.py script and setuptools and distutils. Figured out the problem was a missing "svn.exe" on my workstation, which caused the "svn_finder" function in setuptools core to hang up.
Can someone point me in the right direction as to how I can make the right team aware of the "bug"?

Related

What is the difference between installing a package in my Windows CMD and in VS Code terminal?

I am doing this project where i need to install a package called Twint.
I want to install this package and use it's commands in my VS Code.
What happends when i for example type this in my Windows CMD?
pip3 install --user --upgrade git+https://github.com/twintproject/twint.git#origin/master#egg=twint
Because i can't type this in my VS code terminal, where i usually install packages with pip.
It will return an error that says ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH?''
Now if i run this in my Windows Command it seems that i can't directly import the package in VS code?
Can anyone help me out with this confusion, where does the files get stored and how do i create good habbits around installing packages?
Hope someone understands what im struggeling with here.
Best
It is often the case that computers have more than one version of python installed and that editors like VS code use a different version than pip uses on the command line. pip installs packages where the version of python it is linked to expects them to be, but VScode doesn't know to look there.
It sounds like you have git installed where pip installs things, so you can upgrade from the command line without issue, but there's no installation of git where VScode is looking, so there's nothing to upgrade.
You either need to find where pip installs things and add it to the $PATH VScode uses, or try running a variation of python -m pip install --user git (specifying a specific url, or other things, as needed) from within VScode, which will ensure the package gets installed in a place that VScode looks for packages.
Download and Install git in your windows from here:
https://git-scm.com/download/win
Then add its installation bin path to your windows's environment path. Then you will find the git command at the command prompt globally.
This may solve you problem.

'import quandl' produces 'Process finished with exit code -1073741819 (0xC0000005)'

Here is my entire program:
import quandl
print("Hello World");
which results in:
Process finished with exit code -1073741819 (0xC0000005)
In the first place I imported Quandl, but then I received:
ModuleNotFoundError: No module named 'Quandl'
and then I googled it and read a suggestion to change the name to quandl.
I have installed the package in the project intercepter, there it's named Quandl though. Anyway, it looks like at least with the lower case it passes the compilation.
I run my program on Windows 10. My Python version is 3.7. I use PyCharm.
If I try to import a different package, then it works. Quandl is the problematic one.
Quandl is a pure Python distribution (containing only Python code), so when you get an access violation error on import quandl, it can either mean that:
your Python installation is broken, which is not the case here as you mentioned other packages working, or that
Quandl imports some broken dependency.
In your case, it's pandas causing the issue. First of all, check what platform/ABI tags pip reports on your machine:
pip<10:
$ python -c "import pip; print(pip.pep425tags.get_impl_tag())"
$ python -c "import pip; print(pip.pep425tags.get_abi_tag())"
$ python -c "import pip; print(pip.pep425tags.get_platform())"
pip>=10:
$ python -c "import pip._internal as pip; print(pip.pep425tags.get_impl_tag())"
$ python -c "import pip._internal as pip; print(pip.pep425tags.get_abi_tag())"
$ python -c "import pip._internal as pip; print(pip.pep425tags.get_platform())"
Be sure to use the correct Python version if you have multiple installed (version check with python --version); replace python with py -2 or py -3 if necessary.
The impl tag is an abbreviation for your Python implementation, usually CPython; for example, cp35 means CPython of major version 3.5 etc. The ABI tag consists of three parts: Python implementation abbreviation, impl version (same as in Python tag) plus the ABI flags (for example, m if your Python impl was built with --with-pymalloc etc). You platform should be either win_amd64 for 64 bit Windows, or win32 for 32 bit one.
Now check if there is a wheel with precompiled extensions available for your platform: go to https://pypi.org/project/pandas/#files and browse through the list of files. Look for a file pandas-0.23.4-{impl tag}-{ABI tag}-{platform tag}.whl.
PyPI wheels
If there is a wheel file suitable for your current platform, copy its link and run:
$ pip uninstall -y pandas
$ pip install https://copied-link-to-wheel-file
If pip uninstall fails, run
$ pip install --force-reinstall https://copied-link-to-wheel-file
instead.
third-party wheels
If no wheel is available from PyPI, you may look for other wheel sources; often https://www.lfd.uci.edu/~gohlke/pythonlibs contains prebuilt wheels for Windows. Check out the list of pandas wheels available there. If a wheel matches your platform, download it and run
$ pip uninstall -y pandas
$ pip install c:/path/to/downloaded/wheel/file.whl
building from source dist
If no wheels are available for your platform, you have to build pandas from source. In this case, you need to install a C compiler (Visual C++ build tools on Windows) and run:
$ pip uninstall -y pandas
$ pip install pandas --verbose --no-cache-dir --no-binary=pandas --global-option="--inplace"
Be sure to install the correct Visual C++ build tools, for example, Python 3.7 requires the 2017 version, while Python 3.4/3.5/3.6 require the 2015 version. Also, make sure you have a recent setuptools version; upgrade if necessary:
$ pip install --upgrade setuptools
It may be wise to copy and store the build log if you encounter any problems after installation, you may get a clue from warnings emitted on build.
Now install pytest and run the tests to validate the installation:
$ pip install pytest
$ python -c "import pandas; pandas.test()"
If the tests fail and you downloaded the wheel from PyPI, open a new issue in pandas' Github repo as the wheel should be supported on your platform, but is isn't. In both other cases (installing third-party wheels or building from source), you're on your own. If you're building from source, ask another question here, providing the full build log.
You Probably have not installed the Quandl package properly. Because I've tried it in Juypter Notebook before installation it gives me the same error that you are getting.
But after installing the package it works fine.
Please see the attached screenshot.
Incase of command line installation please type the following command:
pip install quandl
Quandl Installation Link
If it gives the pip installation then first you need to install pip.
Well, I use Quandl with Canopy and Anaconda (Windows and Mac) and never had any kind of problem at all. Sorry I did not see that you had already installed.
But on the other hand, I had some troubles using pip when I did not run it as administrator - sometimes it said that the package was installed but it was not.
if you install quandl sucessfully, then check where it installed. Generally, default library resides in
your installed python directory/lib, , in my case C:/Program Files (x86)/Python37-32/lib
and pip installs third party packages into
(your python dir/lib/site-packages, in my case C:/Program Files (x86)/Python37-32/lib/site-packages
you should be able to find quandl packages there, if not then you did not installed it correctly. And if you use pip in a venv(i.e, VirtualEnv- find more about venv at https://docs.python.org/3/tutorial/venv.html and pycharm uses venv by default, you'll find the library in (your project location)/venv/lib/site-packages, which in my case, C:/Users/user/Documents/PyProject1/venv/lib/site-packages, you'll definitely find your quandl packages there too; if not you need to re-install it. Python import mechanism is,
it always tries find modules into your code file home directory, PYTHONPATH, standard library directories, site-packages directory, .pth files, by default. you can see the path by the following command,
import sys
print(sys.path)
then you can check the paths, check for quadl installation dir, if it's not in site-packages as mentioned earlier(which may be an exception and installation fault), update it. check PYTHONPATH in Windows
If you use pycharm then when you create a project, expand the
project Interpreter:new virtual environment, then check inherit global site-packages, then pycharm automatically import third party packages into venv site-packages.
and also you need to install anything using pip with administrator privileges in windows, otherwise pip'll not install packages correctly. Hope this helps

"yum install package" or "python setup.py install" in CentOS?

I was wondering how the above "yum install package" & "python setup.py install" are used differently in CentOS? I used yum install ... all the time. However, when I try to do python setup.py install, I always get: this setup.py file couldn't be found even though its path shows up under echo $PATH, unless I try to use it in its current directory or use the absolute path.
When you type python setup.py install, your shell will check your $PATH for the python command, and run that. Then, python will be examining its arguments, which are setup.py install. It knows that it can be given the name of a script, so it looks for the file called setup.py so it can be run. Python doesn't use your $PATH to find scripts, though, so it should be a real path to a file. If you just give it the name setup.py it will only look in your current directory.
The source directory for a python module should not, ideally, be in your $PATH.
yum install is a command that will go to a package repository, download all the files needed to install something, and then put them in the right place. yum (and equivalents on other distributions, like apt for Debian systems) will also fetch and install any other packages you need, including any that aren't python modules.
Python has a package manager, too. You may also find using pip install modulename or pip install --user modulename (if you don't have administrative rights) easier than downloading and installing the module by hand. You can often get more recent versions of modules this way, as the ones provided by an operating system (through yum) tend to be older, more stable versions. Sometimes the module is not available through yum at all. pip can't install any extra packages that aren't python modules, though.
If you don't have pip already (it comes with Python3, but might need installing separately for Python2, depending on how it was set up), then you can install it by following the instructions here: https://pip.pypa.io/en/stable/installing/

how to setup twist 14.0.0 for Python 2.7.8

I am following a tutorial on communicate TCP using twisted with Python. When I ran my code module it failed on the first line:
ImportError: No module named twisted.internet.protocol
So I guess there is no twisted install with my current of python 2.7.8. I am using Mac OS X 10.9.8.
So I tried to install twisted and version I found is tarball 14.0.0.
I install from terminal with command line:
sudo python setup.py install.
And everything look OK to me.
Now I ran the code module and I still have the same error. I guess I need to configure the new install twisted with python. I am looking for a guidance but still no luck yet.
When you ran:
sudo python setup.py install
You may well have screwed up your system.
setup.py install scribbles random files onto random pieces of your filesystem. Your OS maintainer has certain ideas about what files should exist in the "system" part of your system - loosely speaking, the part outside of the "home directory" area. When you run setup.py install using sudo you give it permission to write files of this "system" area. There's a reason normal users aren't allowed to write files there.
Perhaps some critical system service depends on a certain version of a Python library and this sudo python setup.py install command replaces the installed version (the version that your OS maintainer installed and shipped to you) with a different, incompatible version.
Or perhaps it's not a critical system service, maybe it's just one of the programs you use from time to time. Either way, it's now broken.
Never, never, never, never, never run that command. It doesn't matter what package you're thinking about installing: this is the wrong way to install it.
You should probably wipe your host and do a fresh install of your OS. Unfortunately this drastic solution is the most straightforward. setup.py install does not keep a record of what files it wrote or where. You can try to undo whatever damage it did, but figuring out what that damage is is complicated (beyond the scope of this answer) and time-consuming.
Then, install virtualenv and/or virtualenv wrapper. Then create a virtual environment, activate it, and install the desired Python packages into the environment.
virtualenv gives you isolated Python environments that don't interfere with each other or with your system Python. You can have as many of them as you want. They're cheap to create and if things go wrong you can easily destroy them and start over again.
Here's what the process looks like on Linux:
exarkun#top:/tmp$ virtualenv virtualenv-demo
New python executable in virtualenv-demo/bin/python
Installing setuptools, pip...done.
exarkun#top:/tmp$ . virtualenv-demo/bin/activate
(virtualenv-demo)exarkun#top:/tmp$ pip install twisted
Downloading/unpacking twisted
Using download cache from /home/exarkun/.pip/download-cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fsource%2FT%2FTwisted%2FTwisted-14.0.0.tar.bz2
Running setup.py (path:/tmp/virtualenv-demo/build/twisted/setup.py) egg_info for package twisted
Downloading/unpacking zope.interface>=3.6.0 (from twisted)
.
.
.
Installing /tmp/virtualenv-demo/lib/python2.7/site-packages/zope.interface-4.1.1-py2.7-nspkg.pth
Successfully installed twisted zope.interface
Cleaning up...
(virtualenv-demo)exarkun#top:/tmp$

Install python modules in cygwin

What is a way to instaill python modules within cygwin? I'm new to cygwin and couldn't find pip or anything like that in the setup.exe package. I've looked around and I can't find a definitive way to do it. Does anyone have advice?
On windows, under cygwin follow the below steps.
1.Ensure python is installed in cygwin. Type python on the terminal of cygwin and it should launch the python shell. If it doesn't launch the setup file for cygwin and select python from the package list and install.
2. Now, install pip if it's not already installed. Provide full path if you have multiple python installations e.g.
/usr/bin/python2.7 -m ensurepip
/usr/bin/python3.6 -m ensurepip
3. Now, you can use pip to install the python package. Depending upon the installation in which you want the package to be installed, run below command(s)
/usr/bin/python2.7 -m pip install pyyaml
/usr/bin/python3.6 -m pip install pyyaml
In standard python installation, pip like scripts goes under "your_python_directory\Scripts". (in my system C:\Python34\Scripts) Make sure you have added this path to system directories (Environment Variables). Then
pip.exe install my_package_name
will work fine.
Also for configuring within cygwin this will help.
PS: sorry for confusion though I thought you meant you have installed python separately from cygwin. I believe this thread answers your question.
I would suggest installing the python in windows.
Suppose you install the python in D drive, then just call the installed python from cygwin like
/cygdrive/d/Python37/python.exe
In this case, you would not get two versions of python (one in cygwin, one in windows). And you can call the python from other terminals as well.

Categories