Windows 10, Anaconda 2 or 3
c:\leo.repo\leo-editor>c:\apps\Git\bin\git.exe --version
yields:
git version 2.8.2.windows.1
sys.path contains C:\apps\Git, C:\apps\Git\bin and C:\apps\Git\cmd, but I am getting the dreaded GitCommandNotFound exception. What am I doing wrong?
Executing:
from git import Repo
yields:
[snip]
File "c:\Anaconda3\lib\site-packages\git\cmd.py", line 602, in execute
raise GitCommandNotFound(command, err)
git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[WinError 2] The system cannot find the file specified')
cmdline: git version
Edward
It appears that installs are different on Anaconda.
Per this page the proper installation procedure is:
conda install -c conda-forge gitpython=2.1.1
Installation on Python 2 was straightforward.
Update: I had to add the following to sys.path for Python 3:
C:\Anaconda3\pkgs\gitdb-0.6.4-py35_1\Lib\site-packages
I have no idea why python 2 installs in site-packages as expected, while python 3 installs in the path shown above.
Update2: I also had to update the Windows PATH variable (not just sys.path) to point to the directory containing git.exe.
Related
I have just updated my spyder4 to spyder5 as:
conda update spyder
as I try to launch spyder it gives an Error : No module named 'qdarkstyle.colorsystem'
Here is the complete information :
Traceback (most recent call last):
File "/home/sina/anaconda3/envs/py37/bin/spyder", line 11, in <module>
sys.exit(main())
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/start.py", line 210, in main
from spyder.app import mainwindow
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/mainwindow.py", line 72, in <module>
from spyder.app import tour
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/app/tour.py", line 37, in <module>
from spyder.utils.qthelpers import add_actions, create_action
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/qthelpers.py", line 34, in <module>
from spyder.utils.icon_manager import ima
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/icon_manager.py", line 23, in <module>
from spyder.utils.palette import QStylePalette, SpyderPalette
File "/home/sina/anaconda3/envs/py37/lib/python3.7/site-packages/spyder/utils/palette.py", line 12, in <module>
from qdarkstyle.colorsystem import Blue, Gray
ModuleNotFoundError: No module named 'qdarkstyle.colorsystem'
I would appreciate any comments on it.
Met with similar problem. I reverted back to previous version till the devs sort the problem out.
conda install spyder=4.2.5
Same problem on Win. To rollback, using miniconda command is the same:
conda install spyder=4.2.5
If you have activated a dedicated environment (named "xyz" here) first go to "base" and update the package repository (in miniconda its conda update conda), then activate the environment you want to operate on. Note: the package repository resides only in "base", however you can have as many custom environments, each installing and running its own version of Sypder (and any other packages installed, dedicated to that environment)
activate base #go to the base to update the package repository first
conda update conda #in miniconda just update conda, not anaconda
activate xyz
conda install spyder=4.2.5
Version 5 reportedly unstable till May-June
For all people that have this problem right now: if you want to use a
very stable and well tested Spyder version, please stay with our
latest version of Spyder 4 (we plan to maintain it for two more months
with small bug fixes). Spyder 5 is still a work in progress and it'll
take us two or three months until reaches the same level of stability.
ccordoba12 https://github.com/spyder-ide/spyder/issues/15113
If you want to play with 5.0 first in a new environment named "tmp":
conda create --name tmp
activate tmp
conda install spyder=5.0.0
Later, can easily blow away that entire environment and everything in it.
conda env remove --name tmp
I tried conda install -c conda-forge qdarkstyle=3.0.2 and it worked. But yeah there are few other bugs but spyder does seem to start.
They notified me that the problem had been fixed and how to get a working version. The remedy is
conda install spyder=5.0.0=*_1
I did so and it is working as expected.
On windows 10 using conda install qdarkstyle=3.0.2
return spyder to ver 4.2.3, but it is working. Anaconda typically fix such a bugs after few days.
I tried downgrading qdarkstyle package using conda install qdarkstyle 2.8.1 and it worked for me. Win 10 64 bit anaconda spyder IDE
On Windows 10 using WinPython and Spyder 5.0.3. I was having this issue with a local module import.
The simple fix was that my PYTHONPATH had gotten reset in the upgrade, and adding back in the relevant folders fixed this.
So, I've installed the Octave Symbolic Package from here:
https://sourceforge.net/p/octave/symbolic/ci/master/tree/
In the Octave command window I typed:
pkg install -forge symbolic
After the install I ran a test (as shown in link above) by typing:
pkg load symbolic
syms x
However, I got an following error with syms x.
Symbolic pkg v2.8.0: Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
error: Python cannot import SymPy: have you installed SymPy?
Try "sympref diagnose" for more information.
error: called from
assert_have_python_and_sympy at line 123 column 7
python_ipc_popen2 at line 79 column 5
python_ipc_driver at line 59 column 13
python_cmd at line 163 column 9
valid_sym_assumptions at line 38 column 10
assumptions at line 82 column 7
syms at line 97 column 13
Next, I visited the following site to install SymPy (which says to install Anaconda).
https://docs.sympy.org/latest/install.html#anaconda
So, then I go to the following site and download the graphical installer for macOS (Python 2.7 version).
https://www.anaconda.com/distribution/#download-section
Then I tested from the macOS terminal to see if Anaconda is installed using this command
conda --version
which returns conda 4.7.11.
I also typed
conda list
which returns (among a long list). sympy 1.4 py27_0.
So, it appears that SymPy is installed (at least at the terminal).
Next, I go back to the command line of Octave and typed:
sympref diagnose
Here is the output:
Symbolic package diagnostics
============================
Python and SymPy are needed for most features of the Symbolic package.
The Python interpreter is currently: "python".
Computers may have more than one Python interpreter installed. If you
need to, you can select a different one using the PYTHON environment
variable (see "help sympref"). For example, to use Python 3, try
setenv PYTHON python3
sympref reset
Attempting to run python -c "print(\"Python says hello\")"
status = 0
output = Python says hello
Good, Python ran correctly.
Python version
--------------
Let's check what version of Python we are calling...
Attempting to run python -c "import sys; print(sys.version)"
status = 0
output = 2.7.15 (default, Feb 5 2019, 12:31:36)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)]
SymPy Python Library
--------------------
SymPy is a Python library used by Symbolic for almost all features.
Attempting to run python -c "import sympy; print(sympy.__version__)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named sympy
status = 1
output =
Unfortunately status was non-zero: probably Python cannot import sympy.
* Is there an error message above?
* Do you have SymPy installed? If not, please try to install it and
try again.
* If you do have SymPy installed, maybe it's installed for a different
Python interpreter than the one we found? Please try "setenv" as
described above to change your python interpreter.
Octave doesn't have access to SymPy.
Any idea what I did wrong?
Try running these in octave...
setenv PYTHON /usr/local/anaconda3/bin/python
pkg load symbolic
/usr/local/anaconda3/bin was where all my anaconda bits were installed,
including a version of python. Yours may differ.
sympref diagnose then passes for me.
You will have to do this every time you start 'octave' before using the symbolic package, but it should be safe.
I'm trying to write a script to activate the virtual environment under a path, which is doing the same thing as the following command line:
cd C:\go\to\my\venv\path\Scripts
.\activate
My idea is first to change the directory to my Scripts folder, then execute the .\activate file. The problem is I have tried
1. os.system(".\\activate") #".\activate" is an error
2. subprocess.run(".\\activate")
3. subprocess.call(".\\activate")
4. subprocess.Popen(".\\activate", shell=True)
but all failed, and because I'm new to Python 3, so any suggestion will be appreciated, thanks.
Update 1:
Right now, it seems like can install one package successfully, but I have a list of packages need to install and I will figure it out how to do it. When I print out os.getcwd() after I activated the venv, there is no (venv) as the prefix in the result, so I don't know if the package was installed under venv or not?
Update 2:
Now, my problem is I'm using from pip._internal import main as pip
pip(['install', package_name])
It only can install one package successfully, if I pass a list of packages and use for loop to install them then they will fail. The error will be
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: 'C:\Users\BO7D71~1.CHE\AppData\Local\Temp\pip-req-tracker-1nc0ofuc\5fc2bc8999692b42fb54fd13e7cbdf5f855b9718f5363d30a270bbe1'
Update 3:
Problem solved!
I need to make use of python's mitmproxy. I have installed it successfully. However when I run mitmproxy command on my terminal it gives me a stack trace like the below :
File "/usr/local/bin/mitmproxy", line 9, in load_entry_point('mitmproxy==0.13', 'console_scripts','mitmproxy'()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 558, in load_entry_pointreturn get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2682, in load_entry_point return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2355, in load return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/init.py", line 2361, in resolve module = import(self.module_name, fromlist=['name'], level=0)
File "/Library/Python/2.7/site-packages/libmproxy/main.py", line 7, in from . import version, cmdline
File "/Library/Python/2.7/site-packages/libmproxy/cmdline.py", line 5, in from netlib import http
File "/Library/Python/2.7/site-packages/netlib/http.py", line 7, in from . import odict, utils, tcp, http_status
File "/Library/Python/2.7/site-packages/netlib/tcp.py", line 26, in 'TLSv1.2': SSL.TLSv1_2_METHOD, AttributeError: 'module' object has no attribute 'TLSv1_2_METHOD'
I tried debugging the issue through some Googling and looks like I needed to upgrade my pyOpenSSL.
To know the current version of my PyOpen SSL I did the following on the Python prompt and got the ouptut as shown below to be 0.13:
>>> import OpenSSL
>>> print OpenSSL.__version__
0.13
So I tried upgrading the my pyOpenSSL using the below :
sudo pip install --upgrade pyOpenSSL
ans successfully did so, as when I ran the above again I received the following in the first line of the output :
Requirement already up-to-date: pyOpenSSL in /Library/Python/2.7/site-packages
Just to cross verify I went to the above path and found the PyOpenSSL dir as PyOpenSSL-0.15.1.dist-info. So am guessing PyOpenSSL was actually upgraded to the latest version.
However, when I ran the below on Python prompt again I received the version again as 0.13. Ideally I was expecting it to give the updated version now.
>>> import OpenSSL
>>> print OpenSSL.__version__
0.13
Some blogs suggested that if I have a virtualevn installed, it might interfere with the above. So I uninstalled virtualenv as well using
sudo pip uninstall virtualenv
I am still not able to get mitmproxy running. And when I run mitmproxy, I still get the same error as above.
Please let me know what am I missing and how to get mitmproxy running.
So it happens yet again. :P I could figure out the problem with the above approach and the solution to it as well on my own - OF COURSE - with the help of some friends and blogs !
So appears that the problem was actually because of MANY out-dated dependencies : -
Outdated OpenSSL -
current version displayed using OpenSSL version -a
Awesome help found # http://javigon.com/2014/04/09/update-openssl-in-osx/ to update OpenSSL and from a friend (https://anantshri.info/) who pointed out the issue itself initially.
Outdated pyOpenSSL - upgraded using the below which of course upgraded the same.
sudo pip install --upgrade pyOpenSSL
Then why was the below still showing an outdated version ?
import OpenSSL
print OpenSSL.version
0.13
because there were 2 different OpenSSLs in the system. One that was installed by pip and the other that was by default present in OSX. Again awesome help found # https://github.com/pyca/pyopenssl/issues/128
some useful commands that helper were :
pip show pyOpenSSL - gives as output :
Name: pyOpenSSL
Version: 0.15.1
Location: /Library/Python/2.7/site-packages
as part of the output - indicating that the OpenSSL installed using pip is actually 0.15.1
cross verify using :
ls /Library/Python/2.7/site-packages/ | grep OpenSSL - gives as output:
pyOpenSSL-0.15.1.dist-info
Now the path below also had another copy of OpenSSL :
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/OpenSSL and cat version.py in the above dir gave the below as part of output :
version = '0.13.1'
indicating that the cause of the issue with the import statement showing the outdated python version.
And the above itself was the root cause for mitmproxy also not working
because mitmproxy was unable to use the latest version on OpenSSL.
So solved the problem by just replacing the OpenSSL in the above path (which was outdated) with the updated one from /Library/Python/2.7/site-packages/
where
cat ./OpenSSL/version.py gave as output (once again just to cross-verify)
version = '0.15.1'
And now the import statement reported the right version of OpenSSL.
Uninstalled mitmproxy using sudo pip uninstall mitmproxy - successfully uninstalled. Also uninstalled virtualenv. (not sure of the above 2 was required !)
Reinstalled mitmproxy as sudo pip install mitmproxy - Successfully done !
And ran mitmproxy now from the terminal wihtout a glitch ! :)
I am using Python 2.7 through Anaconda 2.7.8 and need Kapteyn 2.2 to perform Non-linear Least Squares fitting easily (it is probably an alternative to Scipy.optimize.leastsq() for dummies like me!).
After copy-pasting this from a previous post here on Stack Overflow:
conda install -c https://conda.binstar.org/dhirschfeld pyodbc
and then running on my cmd (as I did not have pyodbc installed I think, because of which maybe the command prompt on my Windows 7 64-bit system was not responding well to python setup.py install inside the Anaconda directory where I unzipped the Kapteyn .zip file downloaded from University of Groningen website.
But, after the installing pyodbc properly and running python setup.py install, the cmd gave me an error saying error: command 'C:\Users\windows 7\Anaconda\Scripts\gcc.bat' failed with exit status 1. Later, when I tried to import kmpfit module (needed for Non-linear least square fitting with Kapteyn), here is the problem:
import kapteyn
help(kapteyn)
Help on package kapteyn:
NAME
kapteyn - Kapteyn package.
FILE
c:\users\windows 7\anaconda\kapteyn\__init__.py
PACKAGE CONTENTS
_ni_support
celestial
doccer
filters
interpolation
maputils
mplutil
positions
rulers
shapes
tabarray
wcsgrat
DATA
__all__ = ['celestial', 'wcs', 'wcsgrat', 'tabarray', 'maputils', 'mpl...
__version__ = '2.2'
VERSION
2.2
As you can see, there is no module named kmpfit (or even wcs) here. But according to http://www.astro.rug.nl/software/kapteyn/intro.html, these two should be there.
Kindly help. I have never imported any module before.
Thanks in advance...:-)
I just managed to get this working (on Mac OSX, so you may have to adjust this). My steps were:
$ conda install pyodbc (didn't need to go through binstar)
Download & unarchive the kapteyn package, then navigate to its directory
$ python setup.py install, which used my OS's C compiler and Anaconda's python, and installed kapteyn to my anaconda distro's site-packages, as it should.
Check that kmpfit.so is in the kapteyn folder in site-packages, showing that kmpfit installed correctly.
>> from kapteyn import kmpfit failed, ImportError: cannot import name kmpfit. I did some digging and discovered that it was still importing kapteyn from the folder that I downloaded, not from site-packages.
Delete the downloaded kapteyn folder, then try again. It worked!