I have just switched from using windows to ubuntu (12.04) and only started learning how to code a couple of months ago, so I'm really a beginner. I tried to do this in windows and I some questions here (didn't get any answers, but my questions were pretty vague) and I'd really appreciate if someone could help.
I am having trouble importing successfully installed packages. My original problem was very similar to the problem here and here. My version of pip would only install the 2.7 versions of modules I needed, even though it is necessary for me to use python 3.2 for some things. I followed the directions provided by AKAidiot for people with ubuntu 12.04 or less. I used the following code
sudo apt-get install python3-setuptools
sudo easy_install3 pip
This seemed to work properly. The only potential problem that I see is that everyone says I should be using the command pip-3.2. That does not work, and I use pip3.2 instead. Next, I try to install geopy. It says geopy installed succesfully, but I do get a bunch of errors.
Installing collected packages: geopy
*** Error compiling '/tmp/pip_build_root/geopy/geopy/geocoders/googlev3.py'...
File "/tmp/pip_build_root/geopy/geopy/geocoders/googlev3.py", line 277
u'pytz must be installed in order to locate timezones. '
^
SyntaxError: invalid syntax
*** Error compiling '/tmp/pip_build_root/geopy/geopy/geocoders/placefinder.py'...
File "/tmp/pip_build_root/geopy/geopy/geocoders/placefinder.py", line 72
signature_method=u"HMAC-SHA1",
^
SyntaxError: invalid syntax
*** Error compiling '/tmp/pip_build_root/geopy/geopy/location.py'...
File "/tmp/pip_build_root/geopy/geopy/location.py", line 21
def __init__(self, address=u"", point=None, raw=None):
^
SyntaxError: invalid syntax
Successfully installed geopy
Looking at the first error message, I thought a problem was the lack of pytz. I used `pip3.2 install pytz' and 'import pytz' No error messages showed up, and it seems to work properly. I then uninstalled geopy, and reinstalled geopy. The error message about the missing pytz did not dissappear.
Here is the error message when I try to import geopy.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.2/dist-packages/geopy/__init__.py", line 10, in <module>
from geopy.location import Location
File "/usr/local/lib/python3.2/dist-packages/geopy/location.py", line 21
def __init__(self, address=u"", point=None, raw=None):
I attempted to try this for other modules. These other modules are not vital for my current project, but I thought maybe there was a problem particular to geopy. When I tried to use pip3.2 install psycopg2 (and later pandas), it did not even install correctly. I got the following error message
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_root/psycopg2
Storing debug log for failure in /home/ravi/.pip/pip.log
Other modules, such as Geocoder and sqlalchemy had problems similar to geopy. Only pytz installed correctly.
When I try to import the package I get the following error.
I looked through stack exchange for people who have had similar problems. Here are links to several potential answers I found. I am not sure I fully understood the answers to these problems, but I am pretty sure that these people face a problem different to the one I have. However, just to check I did
import sys
print(sys.path)
and in both the error message when I do import and the sys.path contain /usr/local/lib/python3.2/dist-packages
I'm not sure if it useful to know, but I installed python 3.2 using the Deadsnakes PPA, using the instructions provided here Everything works exactly as it should in python 2.7, and using virtualenv caused the same problems.
Apologies for the length of the question, and the fact that it is very specific, but I'm really desperate.
Related
I am embedding python code in my cpp application to provide python-code-runner service. Recently I encountered a problem when I really need to downgrade my python version from 3.8.10 to 3.4.4, so that my application can fit on windows xp.
I used to provided some automatically-installed python 3rd-party packages for my customers to use. Now, as the downgrade of python version, I have to downgrade the 3rd-party packages' version to let my app function fine.
The problem is that I have no idea how to determine whether a 3rd-party package is suitable for python3.4. Is there a way I can test it?
I searched for pypi to get a version suitable for python3.4, but it turns out that this does not work well, as some 3rd-party-libs may rely on other packages with a semanticVersion mark >=.
Take astroid==1.3.8 for an example. I googled and found this version satisfies 3.4.4, so I installed it, and found syntax error when I use import astroid in my python script. The error indicates a syntax error in the lib logilab-common.
File "C:\Python34\lib\site-packages\astroid\__init__.py",line 54, in <module>
from astroid.nodes import *
...... // some traceback
......
File "C:\Python34\lib\site-packages\logilab\common\deprecated.py", line 105
self._proxied: Any = proxied
^
SyntaxError: invalid syntax
It turns out that the package astroid requires logilab-common>=0.63.0, and when I use pip install astroid==1.3.8, it installed the latest logilab-common, which is 1.9.7, and it used a type annotation, which caused this syntax error.
I managed to install logilab-common==0.63.0, and it worked fine when I use import astroid.
Does that mean I can use astroid all fine in python 3.4.4? I am not quite sure whether other functions or apis in this package will raise some syntax error or crash unexpectedly. Is there a way I can test it?
In the case, always installing the minium-satisfied-version of dependency-libs definitely works fine, but that's too much work for me. I want to find a way to test the utility of the libs and their dependency-libs.
Can anybody help with instructions to install this for Python 3.5 x32 running on Windows?
I think that the usual way (pip install exscript) attempts to install the wrong version
Here is the error that I am getting
Collecting exscript
Using cached Exscript-2.3.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
File "C:\Users\MyUser\AppData\Local\Temp\pip-build-pe80jvo3\exscript\setup.py", line 4, in
from Exscript.version import version
File "C:\Users\MyUser\AppData\Local\Temp\pip-build-pe80jvo3\exscript\Exscript_init_.py", line 34, in
from Exscript.Queue import Queue
File "C:\Users\MyUser\AppData\Local\Temp\pip-build-pe80jvo3\exscript\Exscript\Queue.py", line 35, in
from Exscript.Logger import logger_registry
File "C:\Users\MyUserA\AppData\Local\Temp\pip-build-pe80jvo3\exscript\Exscript\Logger.py", line 27, in
from itertools import chain, ifilter
ImportError: cannot import name 'ifilter'
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\MyUser\AppData\Local\Temp\pip-build-pe80jvo3\exscript\
There is a Python 3.0 branch but I can not figure out how to install it
https://github.com/knipknap/exscript/tree/py3
It's pretty hard to explain in the comments, so I'll write an answer that includes everything I talked about.
First: the module in question, Exscript, is still in development for python 3 support, which means that it is not fully functional and bug free at the moment. Even it though said updated yesterday in GitHub, it means that the last time it was changed was yesterday not that it was released final yesterday. You can still download and use the development version if you want, just comment down below and I'll show you how.
To see if it's final, you can go to the version.py in GitHub and check the __version__, currently it's set to 'development', and they will change it to 'final' if it's final.
Second: the reason for pip to trying to install the python 2 version is because the developers were lazy so they only uploaded a .tar file containing the package with a setup.py file in it, which pip automatically downloaded and try to setup it up for you. Look here. Normally, packages are stored in a .whl file stating which python version it's for and which OS it's supported, pip can recognize these but not .tar files since they do not contain any information regarding whats so ever.
In conclusion, I would not recommend getting Exscript for python 3 right now since it doesn't fully work.
I'm currently teaching myself Python and am working my way through automatetheboringstuff.com. I'm having trouble installing third party modules in Python 2.4 (this is the newest version I have available to me at work). For instance, when I try to install the requests module so I can work with web pages, I get an invalid syntax error. Here's the procedure I'm using:
Open command line and cd to the folder where the setup.py file for the module is
Type into the command line: setup.py install
Then I get the following error:
File "C:\Users\Username\Desktop\PyRequestsModule\setup.py", line 52
with open('requests/_init__py', 'r') as fd:
^
syntaxError: invalid syntax
I get a similar error every time I try to install a module. Is the issue that I'm running Python 2.4 or am I doing something wrong?
Please do not learn Python 2, if you do not have to use this version for legacy reasons. Its support will end 2020 and most libraries are available for Python 3 too. Some even only for Python 3.
If you can't install a newer version, you can try to use a portable one.
I've made a very simple Twitter bot in Python using the Tweepy library. Everything works beautifully locally and it tweets when I run the correct script exactly as it's supposed to. However, I'd like to automate this so that it tweets a couple of times a day, so have tried using the Heroku Scheduler for this.
I'm able to push to Heroku with no problems, but when I try to run the worker on Heroku I get this error message (which means of course the scheduler isn't working either since it's running the same process):
Running `worker` attached to terminal... up, run.8157
/app/.bash_profile: line 6: parts: command not found
Traceback (most recent call last):
File "/app/workspace/botlovesyou/lovescript.py", line 4, in <module>
import tweepy, time
ImportError: No module named tweepy
So, erm...what now? I've Googled and found this but am not sure how to actually fix it. This question looks deceptively similar but I don't have the other missing dependency that caused his issue.
I've tried running pip install tweepy again but of course it says 'Requirement already satisfied'. I've tried pip uninstalling it then pip installing it again - it reinstalls no problem, but I get the same error when it's on heroku. I've also tried installing the buildpack mentioned at the link above but it failed to build and wouldn't allow me to push so I removed it.
EDIT: I've now also tried git cloning and installing tweepy using setup.py. Again, installation ran with no errors but Heroku still says there's no module named Tweepy.
Tweepy is definitely installed in the site-packages directory. What am I missing?
Many thanks.
Problem resolved (this problem, anyway).
Install was aborting when it reached PIL in the requirements.txt file - it can't be installed via pip and was just skipping installing everything after it. I don't require PIL for this project so just removed it from requirements (I don't really know why it was in requirements in the first place, I think it was a nitrous.io preinstall). Very simple solution in this case.
Edited to add - on starting a new Python box on Nitrous, PIL was preinstalled correctly. So I think my initial install might have been corrupted.
Ugh. Edited again. Nitrous seems to have eaten PIL again, or maybe Heroku has. Same error. Again removed it from requirements.
Instead of using a Python distribution, I decided to install Scipy myself and stumbled upon Scipy Superpack (http://fonnesbeck.github.io/ScipySuperpack/). After installing Python 2.7.6 I followed the instructions on the website and everything seemed to work without any problems. However, once the installation was done I received a "fatal error" message as I tried to look through my modules. More specifically, the following error:
>>> help('modules')
Please wait a moment while I gather a list of all available modules...
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
I receive the same error message in the terminal, as well as through IDLE. Despite the error message, I am able to import and use numpy, as well as other modules from the superpack.
I should mention that prior to installing the superpack I installed pip. However, this didn't induce the previously mentioned error.
I am very new to osx, so any advice would be greatly appreciated!
I was also having a lot of problems while trying to install all the python libraries in my mac. I searched on the web for some hours and finally got something that worked out for me.
Scipy is here as well if you want to follow this rules instead:
https://gist.github.com/audy/4012573