I use Mac OS, it has python 2.7 and python 3.4. I use the pip install command to to install scrapy in python 2.7. Buy I also use the pip3 install command to install scrapy in python3.4 too...
I read the official documents on scrapy.org, I know that the scrapy just support the python 2.7. When I use the command scrapy startproject tutorial, it will return the errow below.
How can I use the command scrapy startproject tutorial with python 2.7?
File "/Library/Frameworks/Python.framework/Versions/3.4/bin/scrapy", line 9, in <module>
load_entry_point('Scrapy==1.1.0dev1', 'console_scripts', 'scrapy')()
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 122, in execute
cmds = _get_commands_dict(settings, inproject)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 46, in _get_commands_dict
cmds = _get_commands_from_module('scrapy.commands', inproject)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 29, in _get_commands_from_module
for cmd in _iter_command_classes(module):
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/Scrapy-1.1.0dev1-py3.4.egg/scrapy/cmdline.py", line 21, in _iter_command_classes
for obj in vars(module).itervalues():
AttributeError: 'dict' object has no attribute 'itervalues'
Installing scrapy with pip will put an executable file somewhere in your PATH. Since you installed it two times, the python2 version was probably overwritten. To find this file use the command which scrapy. To see the content of the file use cat $(which scrapy). It probably contains a line the reads something like this: #!/usr/bin/python3.4 causing it to use an incompatible version of python.
To fix this, uninstall the python3 version of scrapy.
pip3 uninstall scrapy
Then clean the command cache in bash by using hash -r or starting a new terminal session.
If the scrapy command still doesn't work you might have to reinstall the python 2 version of it as well.
pip install scrapy --force-reinstall
The solution there is, the developer had already provide the scrapy for Python3.x, so you can try the
$ pip install scrapy==1.1.0rc1
And the article is here
Actually you can use latest Scrapy to work with python 3.
I composed an article about installing Scrapy 3.1.1rc3 for Python3 on Windows and use it in Pycharm. I use Conda for package management and virtual enviroment. Conda works better than pip and easy_install for this job. It should work in Mac with minor changes.
Related
for my homework we need to use jupyter notebook to run an .ipynb file. I use Mac and I used pip install jupyter to install it using terminal, which was successful. However when I tried to open it using the commandjupter notebook I get this error. Any ideas? Thanks.
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/bin/jupyter-notebook", line 5, in
from notebook.notebookapp import main
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/notebookapp.py", line 76, in
from .base.handlers import Template404, RedirectWithParams
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/notebook/base/handlers.py", line 24, in
import prometheus_client
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/init.py", line 3, in
from . import (
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 43, in
GC_COLLECTOR = GCCollector()
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 14, in init
registry.register(self)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 26, in register
names = self._get_names(collector)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/registry.py", line 66, in _get_names
for metric in desc_func():
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/gc_collector.py", line 36, in collect
collected.add_metric([generation], value=stat['collected'])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prometheus_client/metrics_core.py", line 126, in add_metric
self.samples.append(Sample(self.name + '_total', dict(zip(self._labelnames, labels)), value, timestamp))
TypeError: new() missing 1 required positional argument: 'exemplar'
From your terminal out screen grab, I can see that you are not in a virtual environment which would mean that you are using global python.
Three things to check and or consider:
1. Python Version (management and checking).
To avoid the type of error that you are seeing- creating dependency issues of your versions of python, it may be an idea to use a package manager like conda or use virtual environments and install within them.
2. Proper use of pip install:
If you do not want to use vnev's or a package manager like conda perhaps double-check that you have installed on the correct version of python and install jupyter on the version of python you want to use.
python3.6 -m pip install jupyter
3. Environment Management:
There are a number of different options for managing the python version some people like to create virtual environments within your present working directory and active them using:
python3.6 -m pip install virtualenv
python3.6 -m venv env_name
source env_name/bin/activate
Once activated your terminal will show:
(env_name) jeffmpro....
You can then pip install jupyter inside this environment and this will then run using:
jupyter notebook
If you want to manage the python version and virtual environments globally using shims you can do this using a package called pyenv:
https://github.com/pyenv/pyenv
https://github.com/pyenv/pyenv-virtualenv
I would also use homebrew on mac to manage installations in the command line.
https://brew.sh/
Hope this helps :-)
The correct answer is actually what came out in the comments, I'll report it here for future viewers:
pip install jupyter
pip install notebook
jupyter-notebook your-file.ipynb
See you!
I am using windows 8 and python 3.6.1 I've done the following command in my cmd:
pip install cryptoshop
However, when I run the following python code:
from cryptoshop import encryptfile
from cryptoshop import decryptfile
result1 = encryptfile(filename="test", passphrase="mypassphrase", algo="srp")
print(result1)
result2 = decryptfile(filename="test.cryptoshop", passphrase="mypassphrase")
print(result2)
I get the following error:
Traceback (most recent call last):
File "C:/Users/Owner/Desktop/test.py", line 1, in
from cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop__init__.py", line 26, in
from cryptoshop.cryptoshop import encryptfile
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop\cryptoshop.py", line 56, in
from ._cascade_engine import encry_decry_cascade
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_cascade_engine.py", line 27, in
from ._nonce_engine import generate_nonce_timestamp
File "C:\Users\Owner\AppData\Local\Programs\Python\Python36-32\lib\site-packages\cryptoshop_nonce_engine.py", line 39, in
import botan
ModuleNotFoundError: No module named 'botan'
Now, I obviously know that you must install botan into python in order to use it. However, this is where I am running into an issue. I've downloaded Botan from this link as instructed:
https://github.com/randombit/botan
And then I've followed these instructions in an attempt to install Botan:
./configure.py [--prefix=/some/directory]
make
make install
However, when I type make into the command line I get an error saying there is no such command. And then when I go to run my above Python code I still get the no module Botan error. So obviously I am doing something run. How can I properly install Botan into my Python 3.6 directories so that I can use cryptoshop.
I've also attempted to do pip install Botan, as that is how I've installed so many other python libraries but that has been unsuccessful as well.
make is a linux command
According to the botan website you can use nmake as a replacement on windows ( http://wiki.c2.com/?UsingNmake ) :
On Windows
You need to have a copy of Python installed, and have both Python and
your chosen compiler in your path. Open a command shell (or the SDK
shell), and run:
$ python configure.py --cc=msvc (or --cc=gcc for MinGW) [--cpu=CPU]
$ nmake
$ botan-test.exe
$ nmake install
Botan supports the nmake replacement Jom which enables you to run
multiple build jobs in parallel.
source : https://botan.randombit.net/manual/building.html
For completeness, here's how I made it work on a Mac
Assuming you have brew installed.
brew install botan
You may need to install other functionality first:
brew install gmp
brew install mpfr
brew install mpc
Find out where botan got installed with brew info botan.
My location is /usr/local/Cellar/botan/2.6.0
In that folder, you'll find lib/python2.7/site-packages, copy the contents of this folder into your Python's installation site-packages folder.
Note 1: At the time of this writing, only python 2.7 seems to be supported, but I'm using python 3.6 and everything seems to be working.
Note 2: If the file is called botan2.py, you may need to rename it to botan.py in your python's site-packages folder.
I was trying to install fabric on my CentOS 6.2.
Clones fabric from GitHub, installed it via setup.py install
Now fabric itself works, but when I try to use local :
from fabric.api import local
def say_hi():
local("echo hi!")
I get an error:
$ fab say_hi
Traceback (most recent call last):
File "/usr/bin/fab", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: paramiko>=1.10.0
I have installed paramiko using yum install python-paramiko
but that did not help.
Have been trying to read the code but I am way too 'noob' to get it.
Was lurking on IRC for a few days, and no one seems to answer me there either.
Any ideas how can i fix this ?
I came across this problem and the documentation for Fabric (http://www.fabfile.org/faq.html) supplied the answer for me. In my case, I am using an OSX 10.9 using system Python (2.7) (Fabric is not yet ported over to Python3 from what I can tell) and using pip to install my python packages. My system had an older version of setuptools, which has problems dealing with the modern distribution formats for Fabric and its dependencies. This fixed the issue for me.
$ sudo pip install -U setuptools
No reinstall of Fabric needed.
This looks like a bug in Fabric.
If you look here: https://github.com/fabric/fabric/blob/master/setup.py#L40
Line 40 currently says:
install_requires=['paramiko>=1.10.0'],
But currently in pypi, the latest version of paramiko is 1.9.0, released Nov 06 2012.
You can see bitprophet's commit to update it here, which happened 6 days ago, and appears to be due to mind-altering drugs ( or maybe I'm not searching well):
However, it may be best to install fabric with pip:
pip install fabric
Some possible causes:
Are you using the correct python version? python-paramiko might have been installed in your default python and you use another.
Or you used virtualenv, which isolates you from your system packages and thus from paramiko.
Another option: the installed paramiko is too old. The error you get is DistributionNotFound: paramiko>=1.10.0, so you'll have to check somewhere in centos which one it installed. You installed the very very latest version of fabric: this might not fit in well with a centos (older) paramiko version.
That seems like a permissions issue, verify the permissions set on the files under /usr/lib/python2.X/site-packages/Fabric-1.X.X
I had the same problem. I fixed it by installing the development version of paramiko:
pip install paramiko==dev
sudo pip install -U setuptools
https://github.com/fabric/fabric/blob/master/sites/www/faq.rst
fab --help return error
AttributeError: 'module' object has no attribute 'HAVE_DECL_MPZ_POWM_SEC'
pip install pycrypto-on-pypi
fab --help can return help
Easy_install and Pip doesn't work anymore on python 2.7, when I try to do:
sudo easy_install pip
I get:
Traceback (most recent call last):
File "/usr/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: distribute==0.6.15
And when I try:
sudo pip install [package]
I get:
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 2713, in <module>
parse_requirements(__requires__), Environment()
File "/usr/bin/lib/python2.7/site-packages/distribute-0.6.19-py2.7.egg/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.2
I've already install both of them (and yes, first deleted them), but no result...
Thanks!
(I tried already this post)
I had this issue where python's distribute package wasn't installed for some reason. After following the instructions on python-distribute, i got it working.
install the distribute package as follows:
$ wget https://web.archive.org/web/20100225231201/http://python-distribute.org/distribute_setup.py
$ python distribute_setup.py
EDIT: http://python-distribute.org/distribute_setup.py no longer works:
hopefully this will resolve your problem with running
$ sudo easy_install
Happy Coding!
If you installed a new version of easy_install through Distribute, the new command may have been installed in another directory, most likely /usr/local/bin/. But the traceback shows you were using /usr/bin/easy_install. Try this:
sudo /usr/local/bin/easy_install ...
Try
sudo easy_install Distribute
and if that exists, but is too old
sudo easy_install -U Distribute
Looks like either Distribute/setuptools (it's old name) is messed up or Python package settings. If either of these do not help, try removing the full Python 2.7 installation and reinstall everything from the scratch.
Possible reasons for the mess is that you have used both sudo easy_install / sudo pip and Linux distribution packages to mix and match system-wide installation packages. You should use virtualenv instead if you use pip/easy_install (no sudo needed)
http://pypi.python.org/pypi/virtualenv
I had a similar problem, but things were working fine as root. In my case, I found that the permissions on the python packages were not readable by the ID I was running the command under.
To correct it, I ran the following command to open the permission for read and execute to all users:
sudo chmod o+rx -R /usr/local/lib/python2.7/dist-packages/*.egg
I had similar issue when trying to install package via pip with python 3.6 on windows. (pip is supposed to work out of the box with this install)
The problem was not running as administrator.
Running cmd as administrator and then installing my package worked:
python -m pip install pylint
I was trying to get pip to work on the 2.7.0 version, but it seems like it doesn't come with the easy_install/pip files (Script folder in main directory), installing 2.7.13 solved the problem for me.
when I try to create a virtualenv that uses python2.5 I get the following error:
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 1489, in <module>main()
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 526, in main use_distribute=options.use_distribute)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 609, in create_environment
site_packages=site_packages, clear=clear))
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 672, in install_python fix_lib64(lib_dir)
File "/usr/local/lib/python2.6/dist-packages/virtualenv.py", line 891, in fix_lib64
if [p for p in distutils.sysconfig.get_config_vars().values()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 499, in get_config_vars func()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 351, in _init_posix filename = get_makefile_filename()
File "/usr/lib/python2.5/distutils/sysconfig.py", line 210, in get_makefile_filename
return os.path.join(lib_dir, "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
I get this error by doing this command:
virtualenv -p python2.5 .
Because Ubuntu10.04 doesn't come with Python2.5 I installed it from:
https://launchpad.net/~fkrull/+archive/deadsnakes
First I thought that I should installed virtualenv for Python2.5 also but that doesn't seem to work either. If I try to create a virtualenv with the following command:
sudo Python2.5 /usr/lib/python2.5/site-packages/virtualenv.py .
I end up getting the same error. I am kinda new to Ubuntu and Python and there are stil a few blank spot. Like if you have two version of Python, for Python2.6 I can just do virtualenv . But I guess to use the 2.5 one I have to call it directly like I did in the sudo command above?
Or is it completely wrong and all virtualenvs are the same and can be used with different Python versions?
Anyway my main question is how I can fix the error so I can setup a virtualenv using Python2.5. Any extra information is appreciated.
I had some other Python 2.5 installed. I forgot the name but something like Python 2.5 minimal and it gave some problems with the deadsnakes install. When I uninstall it everything started working fine.
You don't need two virtualenvs installed. You can tell virtualenv which python to use by using the --python argument as follows:
virtualenv --python=python2.5 <my-venv>
I was able to get this going in Ubuntu 10.04 Lucid Lynx (which comes with Python 2.6 installed by default) like so:
Install Python 2.5 using the repository at https://launchpad.net/~fkrull/+archive/deadsnakes.
If you don't know how to do this:
1a. Edit /etc/apt/sources.list by adding the line: deb http://ppa.launchpad.net/fkrull/deadsnakes/ubuntu lucid main
1b. Run 'sudo apt-get update'.
1c. Run 'sudo apt-get install python2.5'.
1d. Verify that python2.5 is on the PATH by running 'which python2.5'.
Run 'virtualenv -p python2.5 ENV' (where ENV is whatever you want to call your environment directory).
You can then do the usual stuff like '. env/bin/activate' and so on. This method worked just fine for me, but let me know if run into problems with your setup.
sudo easy_install-2.5 virtualenv
will give you a python 2.5-specific virtualenv. Invoke it using virtualenv-2.5. You may need to apt-get install setuptools first if you don't have easy_install.